I'm confusing...??? (about VB6 and VB2008 Serial Communication) please help...

Status
Not open for further replies.

boyguitar1

Member level 1
Joined
Nov 8, 2010
Messages
33
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Activity points
1,486
Hello...

Now i'm need to send some command via serial port but I found the issue below.
Example:
1. use VB6
Code:
MSComm1.Output = Chr(192) & Chr(38)
and I used program Free Serial Port Monitor check the command.
I can see as " C0 26 " This is correct!!

2. 1. use VB2008
Code:
 SerialPort1.Write(Chr(192) & Chr(38))
and also I used program Free Serial Port Monitor check the command.
I can see as " 3F 26 " this not correct!! (0x3F = Chr ? = Dec 63 )
Why ???????


Please help me why not ??? or My code is incorrect ??

I tried to do many code but not work!! for VB2008



Thank in advance
boy...
 

If you use the SerialPort1.Write method then the argument must be a byte, not a string.

Convert the chr/hex value to a byte.
 

Can you help give me a example code ?
 

Hope this code will help

Code:
Dim targetNumber(1) As Byte

targetNumber(0) = 192
targetNumber(1) = 38

SerialPort1.Write(targetNumber, 0, targetNumber.Length)
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…