Sending/Receiving Data through COM port

John Cassell

Well-known member
Joined
Mar 20, 2007
Messages
65
Programming Experience
Beginner
Hi There,

First of all my apologies for probably posting in the wrong forum, I just didn't know where to put..

I need to create a system which receives data via a COM port and I have looked around for help but I'm still as stuck as I was at the start!

I thought I would try to locate the simplest code to start with and move on from there but even this is producing errors...

VB.NET:
Sub SendSerialData(ByVal data As String)
    ' Send strings to a serial port.
    Using com1 As IO.Ports.SerialPort = _
            My.Computer.Ports.OpenSerialPort("COM1")
        com1.WriteLine(data)
    End Using
End Sub

It is saying: Error 1 'Using' operand of type 'System.IO.Ports.SerialData' must implement 'System.IDisposable'.

I have looked at the error explanation and it is way over my head.

Can anyone advise where I am going wrong?

Thanks very much

John
 
Back
Top