How to read data from rs232 port

dannytg

New member
Joined
Aug 2, 2011
Messages
1
Programming Experience
Beginner
I'm trying to read data from rs232 port

VB.NET:
Private Sub InPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles InPort1.DataReceived
        Dim StIn, StOut  As String

        StIn = InPort1.ReadExisting
        StOut = StIn
        OutPort.Write(StOut)

        For i = 1 To StIn.Length
            Sys = Mid(StIn, i, 1)
            SetText(Sys)

        Next
    End Sub
When I use the above code I'm able to put received character in a text box, but if I use:

VB.NET:
Private Sub InPort1_DataReceived(ByVal sender As Object, ByVal e  As System.IO.Ports.SerialDataReceivedEventArgs) Handles  InPort1.DataReceived
        Dim StIn, StOut  As String

        StIn = InPort1.ReadExisting
        StOut = StIn
        OutPort.Write(StOut)

        SetText(StIn)

       
    End Sub

only first 2 or 3 characters are putted in text box.

Every help will be greatly appreciated.
Thank you. :)
 
Back
Top