T
tkosel
I need to read data in from a serial port. (Scale is attached that sends
data.) I can read the data from the scale using Hyperterminal just fine.
I created the following code. Can you see why it doesn't work? It loops
forever
never seems to get any input.
Do I need to provide more explanation?
Is there a better way to do it?
Private Sub ReadComm_Click()
Dim V_IncomingDataStream
Me.MSCommU.CommPort = Me.ComPort
Me.MSCommU.Settings = Me.baudrate & "," & Me.Parity & "," & Me.DataBits
& "," & Me.StopBits
If Me.MSCommU.PortOpen = False Then
Me.MSCommU.PortOpen = True
End If
If Me.MSCommU.PortOpen = True Then
Do
V_IncomingDataStream = V_IncomingDataStream & Me.MSCommU.Input
If V_IncomingDataStream <> "" Then
Me.Unparsed = V_IncomingDataStream
Me.ComInputData = Val(Mid(V_IncomingDataStream, 5, 10))
End If
Loop Until InStr(V_IncomingDataStream, "g")
End If
If Me.MSCommU.PortOpen = True Then
Me.MSCommU.PortOpen = False
End If
Done:
End Sub
data.) I can read the data from the scale using Hyperterminal just fine.
I created the following code. Can you see why it doesn't work? It loops
forever
never seems to get any input.
Do I need to provide more explanation?
Is there a better way to do it?
Private Sub ReadComm_Click()
Dim V_IncomingDataStream
Me.MSCommU.CommPort = Me.ComPort
Me.MSCommU.Settings = Me.baudrate & "," & Me.Parity & "," & Me.DataBits
& "," & Me.StopBits
If Me.MSCommU.PortOpen = False Then
Me.MSCommU.PortOpen = True
End If
If Me.MSCommU.PortOpen = True Then
Do
V_IncomingDataStream = V_IncomingDataStream & Me.MSCommU.Input
If V_IncomingDataStream <> "" Then
Me.Unparsed = V_IncomingDataStream
Me.ComInputData = Val(Mid(V_IncomingDataStream, 5, 10))
End If
Loop Until InStr(V_IncomingDataStream, "g")
End If
If Me.MSCommU.PortOpen = True Then
Me.MSCommU.PortOpen = False
End If
Done:
End Sub