Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello
I hope my message find you well
I have problem with programming code by visual basic 2005 to make a program to read the data that come from the serial port of the scale indicator bellow you will find a picture for the code of the program and the data after running the program.
I want to read and appear only one in a textbox from the Instantaneous data. the picture show you the data that I wanted to read and appear but i don't know how can i get this result.the code and the protocol of the indicator you will find it bellow too.
please help me if you can.

scale2 — imgbb.com[^]
scale1 — imgbb.com[^]

What I have tried:

VB
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

        receivedtext(SerialPort1.ReadExisting())

    End Sub

    Private Sub receivedtext(ByVal [text] As String)

        If Me.screen.InvokeRequired Then

            Dim x As New settextcallback(AddressOf receivedtext)

            Me.Invoke(x, New Object() {(text)})

        Else

            Me.screen.Text &= [text]

        End If

    End Sub
Posted
Updated 20-May-17 7:50am
v2
Comments
[no name] 20-May-17 13:23pm    
String.Split.

1 solution

In the following snippet Txt is the string you want to break down
VB
Dim parts = Txt.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
If parts.Length > 3 Then
   TextBox1.Text = parts(3).Replace("kg", "")
End If


For an example of reading the Serial port see Basic serial port listening application[^] (C# I'm afraid) or COM port made simple with VB.NET[^]
 
Share this answer
 
v2
Comments
Mustafa Ahmed 20-May-17 15:58pm    
Thank you very much for you interest.
The code was work but read only one value and stop.
I need from the program to read the weight all the time from the indicators. I mean update the reading.
Please help me If you can.
CHill60 20-May-17 16:02pm    
I've updated my solution with some links to CodeProject articles that should help. I originally though you just wanted to work out how to split the data
Mustafa Ahmed 20-May-17 16:12pm    
thanks for fast replay
I wanted from the program split and read the data all the time from the indicator
thanks again.
[no name] 20-May-17 16:18pm    
Okay go ahead and do that. We aren't here to write your code for you.
Mustafa Ahmed 20-May-17 16:22pm    
Okay,thanks very much, please can you send to me a PDF file about the serial port programming in Visual Basic?
thank you sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900