'every send instructions, below the trigger events, return the data string
Private Sub MSComm1_OnComm ()
Dim Inbyte () As Byte
Dim buffer As a String
Dim max_minstr As String
'read the meter returns data string
Select Case mEvent MSComm1.Com
Case comEvReceive
Inbyte=MSComm1. Input will receive 'is a character in the Inbyte
For I=LBound (Inbyte) To UBound (Inbyte) ', according To data in the form of characters will receive LBound is the first character, UBound was the last
Buffer=buffer + Hex (Inbyte (I)) + CRH (32) the value of the buffer time is hexadecimal number + space
Next I
HHH=1
Case comEvSend
End the Select
Began to take 30 characters' from the right
Max_minstr=Right (buffer, 30)
TxtFields (1). The Text=Val (" & amp; H "& amp; Mid (max_minstr, 1) 'starting from the first value, take all the characters
TxtFields (2). The Text=Val (" & amp; H "& amp; Mid (max_minstr, 1, 1) 'starting from the first value, take 1 characters
TxtFields (3). The Text=Val (" & amp; H "& amp; Mid (max_minstr, 2, 10) 'from the second value, take 10 characters
End Sub
The return value of the VB is
TxtFields (1). The Text return 64
TxtFields (2). Text returns 4
TxtFields (3). The Text returns 0
Excuse me why? They had no problems with a serial port debug elves ah,