有关mscomm控件的程序看不懂
看不太懂,哪位大侠能否帮我解释一下。可以再给分的:)
最好加注释,或者给个流程图:P 谢谢~~~~
MSComm1.Settings = "9600,M,8,1"
If Not MSComm1.PortOpen Then MSComm1.PortOpen = True
MSComm1.InBufferCount = 0
Dim address(1 To 1) As Byte
address(1) = 129 '130=82H 129=81H
MSComm1.Output = address
MSComm1.Settings = "9600,S,8,1"
Do Until MSComm1.InBufferCount > 0
DoEvents
Loop
getbyte = MSComm1.Input
For m = LBound(getbyte) To UBound(getbyte)
b(1) = getbyte(m)
Next m
If (b(1) <> 129) Then GoTo start
MSComm1.InBufferCount = 0
Dim command(1 To 1) As Byte
command(1) = 1 '01H
MSComm1.Output = command
Do Until MSComm1.InBufferCount > 0
DoEvents
Loop
getbyte = MSComm1.Input
For m = LBound(getbyte) To UBound(getbyte)
b(1) = getbyte(m)
Next m
If (b(1) <> 1) Then GoTo start
MSComm1.InBufferCount = 0
Dim D(0 To 14) As Byte
Dim f As Integer
f = 255
For J = 1 To 13
D(J) = C(i, J - 1)
check = check + D(J)
Next J
D(0) = 0
D(14) = check And f
MSComm1.Output = D
Do Until MSComm1.InBufferCount > 0
Loop
getbyte = MSComm1.Input
For m = LBound(getbyte) To UBound(getbyte)
b(1) = getbyte(m)
Next m
If (b(1) <> D(14)) Then GoTo start
'If (b(1) <> 255) Then GoTo start
'MsgBox "ok"
MSComm1.PortOpen = False
Dialog.pbrDownload.Value = i
Next i
Unload Dialog
'MSComm1.PortOpen = False