?? frmbang.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{D959C709-8613-11D1-9840-002078110E7D}#1.0#0"; "as97Popup.ocx"
Object = "{C7AE747C-B9E4-11D7-B0E3-D8165009166E}#7.0#0"; "XPForm.ocx"
Begin VB.Form frmbang
BorderStyle = 0 'None
Caption = "設置棒號"
ClientHeight = 7005
ClientLeft = 0
ClientTop = 0
ClientWidth = 7530
Icon = "frmbang.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 7005
ScaleWidth = 7530
ShowInTaskbar = 0 'False
Begin MSCommLib.MSComm MSComm1
Left = 480
Top = 3720
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Frame Frame2
BackColor = &H00C0FFFF&
Caption = "編輯"
Height = 735
Left = 3120
TabIndex = 3
Top = 5400
Width = 2295
Begin as97Popup.asPopup cmdmodify
Height = 375
Left = 120
Top = 240
Width = 855
_ExtentX = 1508
_ExtentY = 661
Caption = "修改"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 16777088
ScaleWidth = 57
ScaleMode = 0
ScaleHeight = 25
End
Begin as97Popup.asPopup cmddel
Height = 375
Left = 1320
Top = 240
Width = 855
_ExtentX = 1508
_ExtentY = 661
Caption = "刪除"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 16777088
ScaleWidth = 57
ScaleMode = 0
ScaleHeight = 25
End
End
Begin VB.TextBox Text1
BackColor = &H00C0FFC0&
Height = 270
Left = 1920
TabIndex = 1
Top = 4320
Visible = 0 'False
Width = 1200
End
Begin VB.Frame Frame1
BackColor = &H00C0FFFF&
Caption = "加入"
Height = 735
Left = 120
TabIndex = 0
Top = 5400
Width = 2775
Begin as97Popup.asPopup asPopup2
Height = 255
Left = 1680
Top = 240
Width = 855
_ExtentX = 1508
_ExtentY = 450
Caption = "讀入"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 16777152
ScaleWidth = 57
ScaleMode = 0
ScaleHeight = 17
End
Begin as97Popup.asPopup asPopup1
Height = 255
Left = 360
Top = 240
Width = 855
_ExtentX = 1508
_ExtentY = 450
Caption = "添加"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 16777152
ScaleWidth = 57
ScaleMode = 0
ScaleHeight = 17
End
End
Begin XP窗體控件.XPForm XPForm2
Height = 810
Left = 5160
Top = 3960
Width = 1920
_ExtentX = 3387
_ExtentY = 1429
Caption = "設置棒號"
ShowHelpButton = 0 'False
Icon = "frmbang.frx":1272
AlwaysOnTop = 0 'False
ShowFormSize = 0 'False
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3015
Left = 2040
TabIndex = 2
Top = 960
Width = 3495
_ExtentX = 6165
_ExtentY = 5318
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = "棒號"
Caption = "棒號"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "類型"
Caption = "類型"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 1214.929
EndProperty
BeginProperty Column01
ColumnWidth = 1679.811
EndProperty
EndProperty
End
Begin as97Popup.asPopup cmdupdate
Height = 375
Left = 5640
Top = 5640
Width = 975
_ExtentX = 1720
_ExtentY = 661
Caption = "更新"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 12648447
ScaleWidth = 65
ScaleMode = 0
ScaleHeight = 25
End
End
Attribute VB_Name = "frmbang"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn1 As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim flag As Boolean
Public answer As Integer
Dim bang_num As String
Dim Count_Total As Integer
Dim mon_time As String
Dim Time_Date() As String
Dim Niu() As String
Dim Xia_Biao As Integer
Dim receive(9) As Byte
Dim inTinputlen As Integer
Dim flag_end As Boolean
Private Sub asPopup1_Click(Cancel As Boolean)
Dim flag As Boolean
On Error Resume Next
Horizontal Me, RGB(131, 166, 244), RGB(33, 120, 224)
If rs.EOF = False And rs.BOF = False Then
rs.MoveLast
End If
DataGrid1.AllowAddNew = True
DataGrid1.AllowUpdate = True
cmdupdate.Enabled = True
DataGrid1.Refresh
DataGrid1.Col = 1
If rs.EOF <> True And rs.BOF <> True Then
rs.MoveFirst
End If
If rs.EOF = True Or rs.BOF = True Then
Else
Do While rs.EOF <> True
If Len(Trim(rs.Fields(0))) = 0 Then
MsgBox "已經(jīng)有一條空白記錄,不能再增加新空記錄!", , "提示"
flag = False
Exit Do
End If
rs.MoveNext
Loop
If flag Then
rs.MoveLast
With rs
.AddNew
.Fields(0) = ""
.Fields(1) = ""
.Update
End With
End If
End If
End Sub
Private Sub asPopup2_Click(Cancel As Boolean)
'On Error GoTo err_write
On Error Resume Next
Dim strtxt As String
Dim txtsql As String
Dim k As Integer
Dim rs1 As New ADODB.Recordset
Dim i As Integer
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
strset = "9600,n,8,1"
MSComm1.CommPort = strfile
MSComm1.InBufferSize = 1024
MSComm1.OutBufferSize = 512
MSComm1.PortOpen = True
flag_end = False
On Error GoTo err_write
DataGrid1.AllowAddNew = True
Xia_Biao = 0
strtxt = "0"
MSComm1.Output = strtxt
TimeDelay 600
MSComm1.InBufferCount = 0
liqin ("55")
TimeDelay 30
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 9
inTinputlen = 9
ReDim byTinput(9) As Byte
byTinput = MSComm1.Input
For i = 2 To 9
receive(i - 2) = byTinput(i - 1)
Next
Call GetDisplayText
txtsql = "select * from 棒號設置表 where 棒號='" & bang_num & " '"
Set rs1 = conn1.Execute(txtsql)
If rs1.EOF = True And rs1.BOF = True Then
If rs.EOF = False And rs.BOF = False Then
rs.MoveLast
End If
DataGrid1.AllowAddNew = True
rs.AddNew
rs.Fields(0) = bang_num
rs.Fields(1) = ""
rs.Update
Else
frmmsg.msg.MsgChar = "錄入重復"
frmmsg.Show
TimeDelay 30
Exit Sub
End If
'
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = True
cmdupdate.Enabled = True
Exit Sub
err_write:
frmmsg.msg.MsgChar = "硬件或串口問題"
frmmsg.Show
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
If DataGrid1.Col = 0 Then
lpis = DataGrid1.Left + DataGrid1.Columns(0).Left
tpis = DataGrid1.RowHeight * (DataGrid1.Row + 5 + DataGrid1.Row / 12)
Text1.Left = lpis
Text1.Top = tpis - 30
Text1.Text = DataGrid1.Text
Text1.Visible = True
Else
Text1.Visible = False
End If
' If LastCol = 0 Then
End Sub
Private Sub Form_Load()
On Error Resume Next
XPForm2.Make
intport = 1
Dim connecting As String
Dim txtsql As String
connecting = "provider=Microsoft.Jet.oledb.4.0;" & _
"data source=" & App.path & "\jk.mdb"
conn1.Open connecting
txtsql = "select * from 棒號設置表"
rs.CursorLocation = adUseClient
rs.Open txtsql, conn1, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
cmdupdate.Enabled = False
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
100:
'frmmsg.msg.MsgChar = Err.Description
'frmmsg.Show
End Sub
Private Sub cmddel_Click(Cancel As Boolean)
On Error Resume Next
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -