📄 time-tester_1.frm
字号:
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 480
TabIndex = 29
Top = 1920
Width = 135
End
Begin VB.Label Label6
Caption = "3"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 480
TabIndex = 20
Top = 1440
Width = 135
End
Begin VB.Label Label6
Caption = "2"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 480
TabIndex = 19
Top = 960
Width = 135
End
Begin VB.Label Label6
Caption = "1."
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 480
TabIndex = 18
Top = 480
Width = 135
End
Begin VB.Label Label5
Alignment = 2 'Center
ForeColor = &H000000FF&
Height = 255
Left = 240
TabIndex = 9
Top = 3360
Width = 975
End
Begin VB.Label Label4
Caption = "ReBtime(ms)"
Height = 255
Left = 6360
TabIndex = 3
Top = 120
Width = 1455
End
Begin VB.Label Label3
Caption = "OpBTime(ms)"
Height = 255
Left = 4440
TabIndex = 2
Top = 120
Width = 1455
End
Begin VB.Label Label2
Caption = "Rel Time(ms)"
Height = 255
Left = 2760
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.Label Label1
Caption = "Op Time(ms)"
Height = 255
Left = 960
TabIndex = 0
Top = 120
Width = 1095
End
End
Attribute VB_Name = "Time_Tester"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Y() As Byte
Dim flag As Boolean
Dim Test_Times As Byte
Dim m As Byte
Dim Row_Num As Integer
Private Sub Com_OnComm()
Dim X As Integer
Dim z As Single
Select Case Com.CommEvent
Case 1
Exit Sub
Case 2
If flag = False Then
Y = Com.Input
If Y(0) = 0 Then
Label5.Caption = "已连接"
Label5.ForeColor = &HFF0000
Com.RThreshold = 8
flag = True
'ReDim y(8) As Byte
End If
Else
ReDim Y(8) As Byte
'Text7.Text = Row_Num
Y = Com.Input
Select Case m
Case 1
For i = 0 To 6 Step 2
X = 256 * Y(i) + Y(i + 1)
z = X / 100
If z < 1 Then
Text1(i / 2).Text = "0" + CStr(z)
Else: Text1(i / 2).Text = CStr(z)
End If
Next
If m < Test_Times Then
m = m + 1
Else: m = 1
End If
Exit Sub
Case 2
For i = 0 To 6 Step 2
X = 256 * Y(i) + Y(i + 1)
z = X / 100
If z < 1 Then
Text2(i / 2).Text = "0" + CStr(z)
Else: Text2(i / 2).Text = CStr(z)
End If
Next
If m < Test_Times Then
m = m + 1
Else: m = 1
End If
Exit Sub
Case 3
For i = 0 To 6 Step 2
X = 256 * Y(i) + Y(i + 1)
z = X / 100
If z < 1 Then
Text3(i / 2).Text = "0" + CStr(z)
Else: Text3(i / 2).Text = CStr(z)
End If
Next
If m < Test_Times Then
m = m + 1
Else: m = 1
End If
Exit Sub
Case 4
For i = 0 To 6 Step 2
X = 256 * Y(i) + Y(i + 1)
z = X / 100
If z < 1 Then
Text4(i / 2).Text = "0" + CStr(z)
Else: Text4(i / 2).Text = CStr(z)
End If
Next
If m < Test_Times Then
m = m + 1
Else: m = 1
End If
Exit Sub
Case 5
For i = 0 To 6 Step 2
X = 256 * Y(i) + Y(i + 1)
z = X / 100
If z < 1 Then
Text5(i / 2).Text = "0" + CStr(z)
Else: Text5(i / 2).Text = CStr(z)
End If
Next
m = 1
Exit Sub
End Select
End If
End Select
End Sub
Private Sub Command1_Click()
ReDim Y(0) As Byte
Y(0) = &HFF
Com.Output = Y
End Sub
Private Sub Command2_Click()
For i = 0 To 6 Step 2
Text1(i / 2).Text = "0"
Next
For i = 0 To 6 Step 2
Text2(i / 2).Text = "0"
Next
For i = 0 To 6 Step 2
Text3(i / 2).Text = "0"
Next
For i = 0 To 6 Step 2
Text4(i / 2).Text = "0"
Next
For i = 0 To 6 Step 2
Text5(i / 2).Text = "0"
Next
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
ReDim Y(0) As Byte
Y(0) = &H11
Com.Output = Y
End Sub
Private Sub Enter_Click()
ReDim Y(1) As Byte
Y(0) = &H22
Y(1) = Val(Text6.Text)
Test_Times = Y(1)
If Test_Times < 100 Then
Com.Output = Y
Else: MsgBox "输入的数据超出范围.请重新输入!", , "警告!"
End If
End Sub
Private Sub Form_Load()
Label5.Caption = "未连接"
Label5.ForeColor = &HFF
If Com.PortOpen Then Com.PortOpen = False
Com.CommPort = 1
Com.InBufferSize = 1024
Com.OutBufferSize = 1024
Com.InputLen = 0
Com.InputMode = comInputModeBinary
Com.RThreshold = 1
Com.SThreshold = 1
Com.Settings = "4800,n,8,1"
Com.PortOpen = True
flag = False
m = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Com.PortOpen = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -