using mscomm control to communicate with a embedded device

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



hi guys,
i am a new to VB .

i am implementing a VB GUI for an energy meter .A PC will send and
receive modbus frames from the energy meter.
i am using the comm control object in VB
will this work
suppose i need to transmit this Hex frame 01 06 00 08 00 01 CRC
then will this work ?
MSComm1.PortOpen = True
MSComm1.Output = Chr(&H0) & Chr(&H1) & Chr(&H0) & Chr(&H6) & Chr(&H0) &
Chr(&H0) & Chr(&H0) & Chr(&H7) & Chr(&H0) & Chr(&H0) & Chr(&H0) &
Chr(&H1) & Chr(&HD0) & Chr(&HF9)
and i receive the same response from the meter if OK
Dim ValResult As Double
ValResult = Val(MSComm1.Input)
If ValResult Then
MsgBox "Valid response"

Else
MsgBox "No response "
End If
mscomm1.portopen=false
plz tell me whats wrong

.


Quantcast