Feb 11, 2011 #1 B 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...
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...
Feb 11, 2011 #2 bassa Super Moderator Staff member Joined Jul 15, 2007 Messages 1,815 Helped 191 Reputation 402 Reaction score 156 Trophy points 1,353 Location Sri Lanka Activity points 11,245 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.
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.
Feb 11, 2011 #3 B 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 Can you help give me a example code ?
Feb 11, 2011 #4 bassa Super Moderator Staff member Joined Jul 15, 2007 Messages 1,815 Helped 191 Reputation 402 Reaction score 156 Trophy points 1,353 Location Sri Lanka Activity points 11,245 Hope this code will help Code: Dim targetNumber(1) As Byte targetNumber(0) = 192 targetNumber(1) = 38 SerialPort1.Write(targetNumber, 0, targetNumber.Length)
Hope this code will help Code: Dim targetNumber(1) As Byte targetNumber(0) = 192 targetNumber(1) = 38 SerialPort1.Write(targetNumber, 0, targetNumber.Length)