Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - VB program receives binary data from serial port, and the high and low bits are combined into a long data.
VB program receives binary data from serial port, and the high and low bits are combined into a long data.
Although your microcontroller sends binary 1, VB actually receives the character 1, and every 8 characters represent a byte. You can define an integer of 16 bits first. Suppose you define dim a as an integer, and when you receive the first "1", a= 1.

In the second 1, a=a*2+ 1, while if 0, a = a*2+0, a * 2 is equivalent to the left shift. After moving 15 times, you can integrate the high 8 and the low 8 together, and then you can judge whatever you want. I hope I can help you. Remember that the received character should be +0 to be converted into an integer.

If your rdata is already 8 digits, it will be easier to get it. When it is 8, a = rdata●8a = a * 256+rdata number.