Write to Serial Port : SerialPort « Development « VB.Net Tutorial






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
The port 'COM1' does not exist.








7.34.SerialPort
7.34.1.My.Computer.Ports.SerialPortNames
7.34.2.Write to Serial Port