VB.net Program to Demonstrate the Ioexception

You are currently viewing VB.net Program to Demonstrate the Ioexception

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 . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply