Serial Port Communication in VB 2005

I'm trying to use the new SerialPort class in VB 2005, but having slight problems.

I'm trying to capture all the received data from my connected device and output it to a textbox.  This textbox should be append everytime data is received.  I tried using the DataReceived Events but having little luck.  It does not seem to output the received data.  I'm not sure if I should be using the .ReadExisting() function or something else to get the currently received bytes.

There is also a button on the form that will transmit a string to my device when a button is clicked that will cause it to respond.  The application should be able to constantly update the received text not looking for any start/end trigger  (except that the port has been open/closed).

Here is my code

' ============================================
' Variables
Private WithEvents MyDevice As IO.Ports.SerialPort
Delegate Sub SetTextCallback(ByVal [text] As String, ByVal append As Boolean)

' ============================================
' Data Received Event from Serial Port
Private Sub MyDevice_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles MyDevice.DataReceived
        Me.SetReceivedText(CType(sender, IO.Ports.SerialPort).ReadExisting, True)
    Catch ex As TimeoutException
        'ignore time out exception on received text
        'I'm not sure why I would need this here, but put it in because I got an exception thrown once.
    End Try
End Sub

' ============================================
' Thread-safe function to update the received text on the form
Private Sub SetReceivedText(ByVal [text] As String, Optional ByVal append As Boolean = False)
    If Me.tbReceived.InvokeRequired Then
        Dim d As New SetTextCallback(AddressOf SetReceivedText)
        Me.Invoke(d, New Object() {[text], append})
        If append Then
        End If
        Me.tbReceived.Text = [text]
    End If
End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
What is the receive threshold set to?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
neelbakAuthor Commented:
I left it at it's default.  I changed it to 1 byte and everything works fine.
Bob LearnedCommented:
Glad you got it, because that would have been my suggestion.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.