1,453
社区成员
发帖
与我相关
我的任务
分享Private Sub Command4_Click()
Dim saveTimer As Single
Dim flag As Integer
Dim sj(0 To 1) As Byte
sj(0) = &H1
sj(1) = &H4
Text1.Text = "begin"
For i = 0 To 5
On Error Resume Next
saveTimer = Timer
MSComm1.CommPort = i
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
MSComm1.Output = sj
MSComm1.InputLen = 0
While Timer < saveTimer + 2
DoEvents
strBuff = MSComm1.Input
If (strBuff <> Null Or strBuff <> "") Then
Text1.Text = strBuff
Exit For
Else
Text2.Text = i + "不可用"
MSComm1.PortOpen = False
End If
Wend
Next i
End Sub