bradbritton
asked on
Issue with serial port in VS 2005
I am making an app that uses a serial port to listen for incoming data, but for some reason I cannot get it to work. It freezes when I click the button to start the app. Any ideas??
Thanks,
Brad
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
Using com4 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSeri alPort("CO M4")
Do
Dim Incoming As String = com4.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
End Using
Return returnStr
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ReceiveSerialData()
End Sub
End Class
Thanks,
Brad
--------------------------
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
Using com4 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSeri
Do
Dim Incoming As String = com4.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
End Using
Return returnStr
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ReceiveSerialData()
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER