Public Class Tester
Public Shared Sub Main
Dim com1Port As IO.Ports.SerialPort = Nothing
Try
com1Port = My.Computer.Ports.OpenSerialPort("COM1")
com1Port.WriteLine("serialData")
com1Port.Write("serialData")
com1Port.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
If (com1Port IsNot Nothing) Then com1Port.Dispose()
com1Port = Nothing
End Try
End Sub
End Class
|