Private Sub Command1_Click() '写入D0=0
Dim Address As String
Dim SenData As String
MSComm1.Settings = "9600,E,7,1"
MSComm1.InputMode = comInputModeText
Address = "1" + "1000" + "02" + "0000" + Chr(3)
SenData = Chr(2) & Address & SumChk(Address)
MSComm1.PortOpen = True
MSComm1.Output = SenData
End Sub
Private Function SumChk(Dats$) As String 'CheckSum
Dim i&
Dim CHK&
For i = 1 To Len(Dats)
CHK = CHK + Asc(Mid(Dats, i, 1))
Next i
SumChk = Right(Hex$(CHK), 2)
End Function