I am getting junk values in textbox when connected to the comm port is it because my bitrate is wrong, then how could I identify the correct bit rate? I am using VB6 to get data from comm port to which a micro controller is connected
Here I have written code for receiving data at a bitrate of 19200. I just wanted to know how to avoid the junk values but it seems that the bitrate of my microcontroller is 19200
Private Sub Command1_Click()
If (MSComm1.PortOpen = False) Then opening port
MSComm1.PortOpen = True
End If
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
If (MSComm1.PortOpen = True) Then
MSComm1.PortOpen = False
End If
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Form_Load()
With MSComm1
.CommPort = 1
.RThreshold = 1
.RTSEnable = True
.Settings = "19200,N,8,1"
.InputLen = 1000
.SThreshold = 1
.PortOpen = True
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If (MSComm1.PortOpen = True) Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub MSComm1_OnComm()
Dim Buffer As String
Select Case MSComm1.CommEvent
Case comEvReceive
Text1.Text = " "
Buffer = MSComm1.Input
Text1.Text = Text1.Text & Buffer
End Select
End Sub