Error problem ....Type 'MSComm' is not defined
Background
I am using VB.net (express edition)
I have the following code copied from the Microsoft Web Page
How to access serial ports by using VB.Net
I have registrered the MSComm32.ocx
I have added MS Comm Control
I get the persistent error
Type 'MSComm' is not defined (line 9)
Type 'MSComm' is not defined (line 10)
'Input ModeConstants' is not declared (line 23)
(These lines might not be exact the same as I have typed above)
Can anyone get me past this ??? Much appreciated
Foxegg
Background
I am using VB.net (express edition)
I have the following code copied from the Microsoft Web Page
How to access serial ports by using VB.Net
Code:
Module Module1
Sub Main()
'New a MSComm control
Dim MSComm1 As MSComm
MSComm1 = New MSComm
' Buffer to hold input string.
Dim Buffer As String
' Use the COM1 serial port.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read the whole buffer when Input is used.
MSComm1.InputLen = 0
' Open the serial port.
MSComm1.PortOpen = True
Console.WriteLine("Open the serial port.")
' Tell the control to make the Input property return text data.
MSComm1.InputMode() = InputModeConstants.comInputModeText
'Clear the receive buffer.
MSComm1.InBufferCount() = 0
' Send the attention command to the modem.
MSComm1.Output = "ATV1Q0" & Chr(13)
Console.WriteLine("Send the attention command to the modem.")
Console.WriteLine("Wait for the data to come back to the serial port...")
' Make sure that the modem responds with "OK".
' Wait for the data to come back to the serial port.
Do
Buffer = Buffer & MSComm1.Input
Loop Until InStr(Buffer, "OK" & vbCrLf)
' Read the "OK" response data in the serial port.
' Close the serial port.
Console.WriteLine("Read the OK response data in the serial port.")
MSComm1.PortOpen = False
Console.WriteLine("Close the serial port.")
End Sub
End Module
I have registrered the MSComm32.ocx
I have added MS Comm Control
I get the persistent error
Type 'MSComm' is not defined (line 9)
Type 'MSComm' is not defined (line 10)
'Input ModeConstants' is not declared (line 23)
(These lines might not be exact the same as I have typed above)
Can anyone get me past this ??? Much appreciated
Foxegg