Hi, all.
I'm not so good programmer, but I have tried to read from the serial port and display the string content to 4 textboxes. Problem is when I use Mid, then only one piece of the string is displayed.

[Private Sub btnVoltage_Click()
Timer1.Enabled = True
MSComm1.Output = ("B9" & vbCr)

txtDataReceived1.Text = Mid(MSComm1.Input, 5, 4)
txtDataReceived2.Text = Mid(MSComm1.Input, 9, 4)
txtDataReceived3.Text = Mid(MSComm1.Input, 13, 4)
txtDataReceived4.Text = Mid(MSComm1.Input, 21, 4)


End Sub]
Thanks

Recommended Answers

All 3 Replies

try to use TRIM before using MID

To be little more clearer, with the code above only one textbox is showing data, the first one. If I jump over the first textbox the second one will display correct values, but I can only get data to one textbox. There is no spaces in my MSComm1.Input String.

Hi
Ï must put the MSComm1.Input in a variable.
It's working fine now.
Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.