Displaying multiple sensors' data on vb2005
nico
Posts: 28
I need some help here please. I have encounter some problems when sending the data from bs2 to display it in my vb's gui. I need to display readings·from several sensors in my com using bs2 and vb. For now, I am able to display 1 reading from 1 sensor·by using the following codes.
bs2 codes:
SEROUT 16,16468,[noparse][[/noparse]DEC cmDistance]
SEROUT 16,16468,[noparse][[/noparse]LF]
vb codes:
TextBox1.Text = SerialPort1.ReadLine
Now lets say I·want to display·another 2 more sensors cmDistance2 and cmDistance3 in TextBox2 and TextBox3. How do I·do it ?
bs2 codes:
SEROUT 16,16468,[noparse][[/noparse]DEC cmDistance]
SEROUT 16,16468,[noparse][[/noparse]LF]
vb codes:
TextBox1.Text = SerialPort1.ReadLine
Now lets say I·want to display·another 2 more sensors cmDistance2 and cmDistance3 in TextBox2 and TextBox3. How do I·do it ?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
If the values you send are a fixed length this becomes easy.
Here's an example of transmitting three values with a fixed length of 4 digits/bytes (total 12 bytes)
SEROUT tx,baud,[noparse][[/noparse]DEC4 val1,DEC4 val2,DEC4 val3,10]
Of course 4 digits would mean each value is a word value in this case , adjust to suit your values.
In Visual Basic you would treat the 12 character string as an array and parse the values using the index of the array and a·member called Substring
eg
Jeff T.