I have some microcontroller that has some data in its memory. I need to read this data through the serial port using an application and display it. I tried doing this in VB using the MSComm control and the following code
CODE
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Fire Rx Event Every Two Bytes
MSComm1.RThreshold = 2
' When Inputting Data, Input 2 Bytes at a time
MSComm1.InputLen = 2
' 2400 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "1200,N,8,2"
' Disable DTR
MSComm1.DTREnable = False
' Open COM1
MSComm1.CommPort = 1
MSComm1.PortOpen = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MSComm1.PortOpen = False
End Sub
Private Sub MSComm1_OnComm(ByVal sender As Object, ByVal e As System.EventArgs) Handles MSComm1.OnComm
Dim sData As String ' Holds our incoming data
Dim lHighByte As Long ' Holds HighByte value
Dim lLowByte As Long ' Holds LowByte value
Dim lWord As Long ' Holds the Word result
' If comEvReceive Event then get data and display
If MSComm1.CommEvent = comEvReceive Then
sData = MSComm1.Input ' Get data (2 bytes)
lHighByte = Asc(Mid$(sData, 1, 1)) ' get 1st byte
lLowByte = Asc(Mid$(sData, 2, 1)) ' Get 2nd byte
' Combine bytes into a word
lWord = (lHighByte * &H100) Or lLowByte
' Convert value to a string and display
RichTextBox1.Text = CStr(lWord)
End If
End Sub
End Class
But i'm getting an error stating that comEvReceive is not declared. what should i do now?