VB.Net program to demonstrate the IOException
'Vb.Net program to demonstrate the IOException.
Imports System.IO
Imports System.IO.Ports
Module Module1
Sub Main()
Try
Dim data As String
Dim serial As New SerialPort("COM1", 4800, Parity.Odd, 8, StopBits.One)
serial.Open()
data = serial.ReadLine()
serial.Close()
Console.WriteLine(data)
Catch ex As IOException
Console.WriteLine("Exception: " & ex.Message)
End Try
End Sub
End Module
Exception: The port 'COM1' does not exist.
Press any key to continue . . .
Table of Contents