📄 dlgbbzbtest.frm
字号:
Case "39"
HextoAscii = HextoAscii + "9"
Case "2E"
HextoAscii = HextoAscii + "."
Case Else
End Select
Next
End Function
Private Sub Command2_Click()
strCommand = "7EE70300203030312E303030300D000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007904E77E"
Timer1.Enabled = True
End Sub
Private Sub Command3_Click()
strCommand = "7EE7030064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003103E77E"
Timer1.Enabled = True
End Sub
Private Sub Command4_Click()
dlgObjectSelection.Show vbModal
Command5.Enabled = False
Dim x As Integer
For x = 4 To 7
Label2(x).Caption = ""
Next
If ttrain = "100" Then
Select Case tobj
Case " 0"
Label2(4).Caption = "AX/a1x1+ a3x3"
Label2(5).Caption = "11.7±0.5%"
Case " 1"
Label2(4).Caption = "AX/a2x2+ a4x4"
Label2(5).Caption = "11.7±0.5%"
Case " 2"
Label2(4).Caption = "AX/a1x1"
Label2(5).Caption = "23.3±0.5%"
Case " 3"
Label2(4).Caption = "AX/a3c3"
Label2(5).Caption = "126±0.5%"
Case " 4"
Label2(4).Caption = "AX/a3b3"
Label2(5).Caption = "46.7±0.5%"
Case " 5"
Label2(4).Caption = "AX/a3x3"
Label2(5).Caption = "23.3±0.5%"
Case " 6"
Label2(4).Caption = "AX/a2x2"
Label2(5).Caption = "23.3±0.5%"
Case " 7"
Label2(4).Caption = "AX/a4b4"
Label2(5).Caption = "46.7±0.5%"
Case " 8"
Label2(4).Caption = "AX/a4x4"
Label2(5).Caption = "23.3±0.5%"
Case " 9"
Label2(4).Caption = "AX/a6b6"
Label2(5).Caption = "114.5±0.5%"
Case " 10"
Label2(4).Caption = "AX/a6x6"
Label2(5).Caption = "63±0.5%"
Case Else
End Select
ElseIf ttrain = "200" Then
Select Case tobj
Case " 0"
Label2(4).Caption = "AX/a1x1"
Label2(5).Caption = "35.95±0.5%"
Case " 1"
Label2(4).Caption = "AX/a2x2"
Label2(5).Caption = "35.95±0.5%"
Case " 2"
Label2(4).Caption = "AX/a3x3"
Label2(5).Caption = "35.95±0.5%"
Case " 3"
Label2(4).Caption = "AX/a4x4"
Label2(5).Caption = "35.95±0.5%"
Case " 4"
Label2(4).Caption = "AX/a5x5"
Label2(5).Caption = "239.70±0.5%"
Case " 5"
Label2(4).Caption = "AX/a6x6"
Label2(5).Caption = "62.52±0.5%"
Case " 6"
Label2(4).Caption = "AX/b6x6"
Label2(5).Caption = "110.62±0.5%"
Case " 7"
Label2(4).Caption = "AX/a1b1"
Label2(5).Caption = "71.90±0.5%"
Case " 8"
Label2(4).Caption = "AX/a3b3"
Label2(5).Caption = "71.90±0.5%"
Case Else
End Select
ElseIf ttrain = "500" Then
Select Case tobj
Case " 0"
Label2(4).Caption = "AX/a1x1"
Label2(5).Caption = "40.364±0.5%"
Case " 1"
Label2(4).Caption = "AX/a2x2"
Label2(5).Caption = "40.364±0.5%"
Case " 2"
Label2(4).Caption = "AX/a3x3"
Label2(5).Caption = "40.364±0.5%"
Case " 3"
Label2(4).Caption = "AX/a4x4"
Label2(5).Caption = "40.364±0.5%"
Case " 4"
Label2(4).Caption = "AX/a5x5"
Label2(5).Caption = "148±0.5%"
Case " 5"
Label2(4).Caption = "AX/a6x6"
Label2(5).Caption = "148±0.5%"
Case " 6"
Label2(4).Caption = "AX/a7x7"
Label2(5).Caption = "63.429±0.5%"
Case " 7"
Label2(4).Caption = "AX/b7x7"
Label2(5).Caption = "111.0±0.5%"
Case " 8"
Label2(4).Caption = "AX/a8b8"
Label2(5).Caption = "28.645±0.5%"
Case " 9"
Label2(4).Caption = "AX/a9b9"
Label2(5).Caption = "28.645±0.5%"
Case Else
End Select
End If
Command1.Enabled = True
End Sub
Private Sub Command5_Click()
If ttrain = "200" Then
Select Case tobj
Case " 0"
byqData(16) = Label2(6).Caption
byqData(17) = Label2(7).Caption
Case " 1"
byqData(18) = Label2(6).Caption
byqData(19) = Label2(7).Caption
Case " 2"
byqData(20) = Label2(6).Caption
byqData(21) = Label2(7).Caption
Case " 3"
byqData(22) = Label2(6).Caption
byqData(23) = Label2(7).Caption
Case " 4"
byqData(24) = Label2(6).Caption
byqData(25) = Label2(7).Caption
Case " 5"
byqData(26) = Label2(6).Caption
byqData(27) = Label2(7).Caption
Case " 6"
byqData(28) = Label2(6).Caption
byqData(29) = Label2(7).Caption
Case " 7"
byqData(30) = Label2(6).Caption
byqData(31) = Label2(7).Caption
Case " 8"
byqData(32) = Label2(6).Caption
byqData(33) = Label2(7).Caption
Case Else
End Select
End If
Command4.Enabled = True
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Form_Load()
Label1.Caption = "设备未连接"
Dim x As Integer
For x = 4 To 7
Label2(x).Caption = ""
Next
Command4.Enabled = True
End Sub
Private Sub MSComm1_OnComm()
Dim bytInput() As Byte
Dim intInputLen As Integer
Dim x As Integer
Dim n As Integer
Dim Index As Integer
Index = 4
Recordcount = Recordcount + 1
Select Case MSComm1.CommEvent
Case comEvReceive
If Not MSComm1.PortOpen Then
strSet = "4800,n,8,1"
' frmMain.MSComm1(Index).commPort = intPort
MSComm1.Settings = strSet
MSComm1.PortOpen = True
End If
'此处添加处理接收的代码
strHex(Index) = ""
strAscii(Index) = ""
MSComm1.InputMode = comInputModeBinary
intInputLen = MSComm1.InBufferCount
ReDim bytInput(intInputLen)
bytInput = MSComm1.Input
' Call InputManage(bytInput, intInputLen)
' Call GetReceiveText(Index)
Call InputManageTotal(bytInput, intInputLen)
Call GetReceiveTextTotal(Index)
If Recordcount > 1 Then
Dim Y As Long
Dim length
length = Len(strHexAll(Index))
Y = InStrRev(strHexAll(Index), "E77E", -1, vbTextCompare)
x = InStrRev(strHexAll(Index), "7EE7", Y, vbTextCompare)
Dim strTemp As String
strTemp = Mid(strHexAll(Index), x + 4, Y - x - 4)
Dim strState As String
strState = Mid(strTemp, 5, 2)
If strState = "68" Then
Label1.Caption = "设备已连接"
Command2.Enabled = True
Command1.Enabled = False
ElseIf strState = "28" Then
Label1.Caption = "正在测试"
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Timer2.Enabled = True
ElseIf strState = "29" Then
Timer2.Enabled = False
Label1.Visible = True
Label1.Caption = "测试正常结束"
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Dim strValHex As String
strValHex = Mid(strTemp, 7, 14)
Dim strVal As String
strVal = HextoAscii(strValHex)
If Val(strVal) <= Val(Label2(5).Caption) * 1.305 And Val(strVal) >= Val(Label2(5).Caption) * 0.795 Then
Label2(7).Caption = "合格"
Else
Label2(7).Caption = "不合格"
End If
Label2(6).Caption = strVal
ElseIf strState = "2A" Then
Dim strErrCode As String
strErrCode = Mid(strTemp, 7, 2)
Select Case strErrCode
Case "AA"
Label1.Caption = "高低压接反"
Case "55"
Label1.Caption = "量程选择错误"
Case "A5"
Label1.Caption = "未知错误"
Case Else
End Select
ElseIf strState = "6A" Then
Label1.Caption = "设备已断开"
Command3.Enabled = True
End If
Timer1.Enabled = False
End If
Case Else
End Select
End Sub
Private Sub Timer1_Timer()
Call controlCommand1(strCommand)
End Sub
Private Sub Timer2_Timer()
If Label1.Visible Then
Label1.Visible = False
Else
Label1.Visible = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -