📄 frmarm.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "Mscomm32.ocx"
Begin VB.Form FrmARM
Caption = "VB与ARM的通信"
ClientHeight = 6750
ClientLeft = 60
ClientTop = 450
ClientWidth = 9045
LinkTopic = "Form1"
ScaleHeight = 6750
ScaleWidth = 9045
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "查询"
Height = 495
Left = 4200
TabIndex = 32
Top = 2280
Width = 855
End
Begin VB.TextBox Text16
Height = 495
Left = 1320
TabIndex = 28
Text = "Text16"
Top = 4080
Width = 1095
End
Begin VB.TextBox Text15
Height = 495
Left = 1320
TabIndex = 26
Text = "Text15"
Top = 5520
Width = 1095
End
Begin VB.TextBox Text14
Height = 495
Left = 3960
TabIndex = 24
Text = "Text14"
Top = 5520
Width = 1095
End
Begin VB.TextBox Text13
Height = 495
Left = 3960
TabIndex = 22
Text = "Text13"
Top = 4800
Width = 1095
End
Begin VB.TextBox Text12
Height = 495
Left = 3960
TabIndex = 20
Text = "Text12"
Top = 4080
Width = 1095
End
Begin VB.TextBox Text11
Height = 495
Left = 7440
TabIndex = 19
Text = "Text11"
Top = 2400
Width = 975
End
Begin VB.TextBox Text10
Height = 495
Left = 1320
TabIndex = 18
Text = "Text10"
Top = 4800
Width = 1095
End
Begin VB.TextBox Text9
Height = 495
Left = 1680
TabIndex = 17
Text = "Text9"
Top = 2160
Width = 1215
End
Begin VB.TextBox Text8
Height = 495
Left = 4080
TabIndex = 15
Text = "Text8"
Top = 120
Width = 1215
End
Begin VB.TextBox Text7
Height = 495
Left = 1680
TabIndex = 12
Text = "Text7"
Top = 120
Width = 1215
End
Begin VB.TextBox Text6
Height = 495
Left = 6720
TabIndex = 11
Text = "Text6"
Top = 1200
Width = 1815
End
Begin VB.TextBox Text5
Height = 495
Left = 4080
TabIndex = 10
Text = "Text5"
Top = 1560
Width = 1215
End
Begin VB.TextBox Text4
Height = 495
Left = 4080
TabIndex = 7
Text = "Text4"
Top = 840
Width = 1215
End
Begin VB.TextBox Text3
Height = 495
Left = 1680
TabIndex = 4
Text = "Text3"
Top = 840
Width = 1215
End
Begin MSCommLib.MSComm MSComm1
Left = 8280
Top = 240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InBufferSize = 0
OutBufferSize = 0
End
Begin VB.CommandButton CmdExit
Caption = "退出"
Height = 495
Left = 5400
TabIndex = 3
Top = 5160
Width = 855
End
Begin VB.TextBox Text2
Height = 495
Left = 6720
TabIndex = 2
Text = "Text2"
Top = 1800
Width = 1815
End
Begin VB.CommandButton CmdSend
Caption = "发送"
Height = 495
Left = 5400
TabIndex = 1
Top = 4080
Width = 855
End
Begin VB.TextBox Text1
Height = 495
Left = 1680
TabIndex = 0
Text = "Text1"
Top = 1560
Width = 1215
End
Begin VB.Label Label16
Caption = "性别"
Height = 375
Left = 6720
TabIndex = 31
Top = 2520
Width = 495
End
Begin VB.Label Label15
Caption = "年龄性别"
Height = 375
Left = 360
TabIndex = 30
Top = 4920
Width = 735
End
Begin VB.Label Label14
Caption = "乘客ID:"
Height = 495
Left = 360
TabIndex = 29
Top = 4200
Width = 855
End
Begin VB.Label Label13
Caption = "时间:"
Height = 495
Left = 480
TabIndex = 27
Top = 5520
Width = 735
End
Begin VB.Label Label12
Caption = "体重:"
Height = 495
Left = 2880
TabIndex = 25
Top = 5640
Width = 855
End
Begin VB.Label Label11
Caption = "到层:"
Height = 495
Left = 2880
TabIndex = 23
Top = 4920
Width = 855
End
Begin VB.Label Label10
Caption = "起层:"
Height = 495
Left = 2880
TabIndex = 21
Top = 4200
Width = 855
End
Begin VB.Label Label9
Caption = "性别"
Height = 495
Left = 960
TabIndex = 16
Top = 2160
Width = 495
End
Begin VB.Label Label8
Caption = "年龄组"
Height = 285
Left = 3360
TabIndex = 14
Top = 240
Width = 570
End
Begin VB.Label Label7
Caption = "乘客ID:"
Height = 285
Left = 720
TabIndex = 13
Top = 240
Width = 810
End
Begin VB.Label Label4
Caption = "到层"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 3360
TabIndex = 9
Top = 1680
Width = 570
End
Begin VB.Label Label3
Caption = "起层"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 3360
TabIndex = 8
Top = 960
Width = 570
End
Begin VB.Label Label2
Caption = "体重"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 960
TabIndex = 6
Top = 1680
Width = 570
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "时间"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 960
TabIndex = 5
Top = 960
Width = 570
End
End
Attribute VB_Name = "FrmARM"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public conn As New ADODB.Connection
Private Sub CmdExit_Click()
End
End Sub
Private Sub CmdSend_Click()
For j = 0 To 2499
Text7.Text = Val(Text6.Text)
Text6.Text = Val(Text6.Text) + 1
Dim connectionstring As String
Dim adors As New ADODB.Recordset
connectionstring = "provider=microsoft.jet.oledb.4.0;data source=dianti.mdb"
conn.Open connectionstring
adors.Open "select * from 乘客信息表 where 乘客ID like '%" & Text7.Text & "%'", conn, adOpenStatic
If adors.RecordCount > 0 Then
Text1.Text = adors.Fields(7) '体重
Text4.Text = adors.Fields(1) '起层
Text5.Text = adors.Fields(2) '到层
Text3.Text = adors.Fields(5) '时间
Text8.Text = adors.Fields(3) '年龄组
Text9.Text = adors.Fields(4) '性别
End If
If adors.Fields(1) <= 9 Then
Text12.Text = "0" + Text4.Text '起层
Else
Text12.Text = Text4.Text
End If
If adors.Fields(2) <= 9 Then
Text13.Text = "0" + Text5.Text '到层
Else
Text13.Text = Text5.Text
End If
If adors.Fields(7) <= 99 Then
Text14.Text = "0" + Text1.Text '体重
Else
Text14.Text = Text1.Text
End If
'时间
If (0 < adors.Fields(5)) And (adors.Fields(5) <= 9) Then
Text15.Text = "0" + "0" + "0" + Text3.Text
ElseIf (10 <= adors.Fields(5)) And (adors.Fields(5) < 100) Then
Text15.Text = "0" + "0" + Text3.Text
ElseIf (100 <= adors.Fields(5)) And (adors.Fields(5) < 1000) Then
Text15.Text = "0" + Text3.Text
ElseIf (1000 <= adors.Fields(5)) And (adors.Fields(5) < 10000) Then
Text15.Text = Text3.Text
End If
If (0 < adors.Fields(0)) And (adors.Fields(0) <= 9) Then
Text16.Text = "0" + "0" + "0" + Text7.Text
ElseIf (10 <= adors.Fields(0)) And (adors.Fields(0) < 100) Then
Text16.Text = "0" + "0" + Text7.Text
ElseIf (100 <= adors.Fields(0)) And (adors.Fields(0) < 1000) Then
Text16.Text = "0" + Text7.Text
ElseIf (1000 <= adors.Fields(0)) And (adors.Fields(0) < 10000) Then
Text16.Text = Text7.Text
End If
'年龄组性别
If (adors.Fields(3) = "成年") And (adors.Fields(4) = "男") Then
Text10.Text = "0"
ElseIf (adors.Fields(3) = "成年") And (adors.Fields(4) = "女") Then
Text10.Text = "1"
ElseIf (adors.Fields(3) = "青年") And (adors.Fields(4) = "男") Then
Text10.Text = "2"
ElseIf (adors.Fields(3) = "青年") And (adors.Fields(4) = "女") Then
Text10.Text = "3"
End If
'性别
' If adors.Fields(4) = "男" Then
' Text11.Text = "M"
' Else
' Text11.Text = "W"
' End If
Set adors = Nothing
Set conn = Nothing
Dim str As String
' If Option1.Value = True Then
' Text6.Text = "M"
' End If
' If Option2.Value = True Then
' Text6.Text = "W"
' End If
Dim sstr(0 To 2) As String
Dim m As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
Dim str5 As String
Dim str6 As String
Dim str7 As String
Dim str1 As String
str1 = Text16.Text '乘客ID
str2 = Text12.Text '起层
str4 = Text13.Text '到层
str3 = Text10.Text '年龄组
' str5 = Text11.Text '性别
str6 = Text15.Text '时间
str7 = Text14.Text '体重
' str = Text16.Text + Text12.Text + Text13.Text + Text10.Text + Text15.Text + Text14.Text
sstr(0) = str1 + str2 + str3 + "##"
sstr(1) = str4 + str6 + str7
' MSComm1.Output = Chr(&HFF) + str
For i = 0 To 1
MSComm1.Output = Chr(&HFF) + sstr(i)
MSComm1.PortOpen = False
MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
MSComm1.PortOpen = True
Next i
' MSComm1.Output = Chr(&HFF) + str1 + str2 + str3 + str4 + str6 + str7 + Chr(&HB)
'MSComm1.Output = "&HFF+&H80+05 08 00"
Next j
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.InputMode = 0
MSComm1.RThreshold = 20
MSComm1.SThreshold = 1
MSComm1.Settings = "115200,n,8,1"
MSComm1.PortOpen = True
MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
End Sub
'Private Sub MSComm1_OnComm()
' Dim Inbyte() As Byte
' Dim buffer As String
' Dim aaa As Variant
' Dim b(0 To 4) As String
' Dim bb As String
' With MSComm1
' Select Case .CommEvent '判断MSComm1通信事件
' Case comEvReceive '收到Rthreshold个字节产生的接收事件
' Inbyte = .Input
' For i = LBound(Inbyte) To UBound(Inbyte)
' buffer = buffer + Hex(Inbyte(i)) + Chr(32)
' Next i
' Text2.Text = buffer
' Text1.Text = ""
'Text2.Text = ""
'Text3.Text = ""
'Text4.Text = ""
'Text5.Text = ""
'Text6.Text = ""
' Case Else
' End Select
' End With
'End Sub
Private Sub Label1_Click()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -