PDA

View Full Version : Data sending to BS2 from VB Express



ctrlBuff
02-19-2010, 02:01 PM
·I am trying to send data to the BS2 with VB Express. I am using the visual basic statement:

SerialPort.Write(Chr(128))

The code works great for any number 0 - 127. Any number from 128 to 255 is received by the BS2 as 63.

The attached screen shot shows the stamp terminal program running with the VB program on top. The screen shot shows the numbers·0 - 127 and 63 for numbers 128 - 255.

Is there a· way to show the correct numbers 128 - 255?

Unsoundcode
02-19-2010, 09:20 PM
Hi , there is another way to use the Write instruction and that is to write a buffer array of bytes , or one byte if you wish.

Dim my_array(1) As Byte

my_array(0)=223

SerialPort1.Write(my_array,0,1)

the above creates an array of the type byte with one element and assigns a value to that element.

The write instruction requires the array name , the index value to start writing from and the number of bytes to write.

Jeff T.

ctrlBuff
02-20-2010, 03:03 PM
Thanks, Jeff, for the array setup. It worked great. I even expanded it so I can send word data up to 65535.

Rich V W