帮忙分析一下:
Private Sub Command6_Click()
Dim SendStr As String
Dim RecStr1, RecStr2 As String
Dim T1, T2 As Integer
Dim I1, I2, I3, I4 As Integer
Dim Sum As String
Dim Ad As Integer
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,7,1"
MSComm1.PortOpen = True
SendStr = "02FFWR0Y000003"
T2 = 0
For I1 = 1 To Len(SendStr)
T1 = Asc(Mid$(SendStr, I1, 1))
T2 = T2 + T1
Next I1
Sum = Hex$(T2)
Sum = Right$(Sum, 2)
SendStr = Chr(5) & SendStr & Sum
MSComm1.Output = SendStr
RecStr1 = ""
RecStr2 = ""
For I2 = 1 To 30000
RecStr1 = MSComm1.Input
If Len(RecStr1) > 0 Then
RecStr2 = RecStr2 & RecStr1
End If
If Len(RecStr2) >= 88 Then
Exit For
End If
Next I2
For Ad = 1 To 10
If Mid$(RecStr2, Ad, 1) = "F" Then Exit For
Next
If Len(RecStr2) >= 20 Then
Text1(5).Text = Mid(RecStr2, Ad + 2, 12)
MSComm1.PortOpen = False
Else
MSComm1.PortOpen = False
MsgBox "通信出错,请检查通信连线及相关设定是否正确!", vbOKOnly, "提示"
End If
End Sub
为民族的水处理事业作出贡献,再取得自己的利益.