0% found this document useful (0 votes)
11 views1 page

Exception Handling Program Guide

GAD 23

Uploaded by

Decoder X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Exception Handling Program Guide

GAD 23

Uploaded by

Decoder X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

-----------------------------------------------------------------------------------------------------------------

---------- Practical No. : 23


Practical Name : Write a program using Exception handaling
Roll No. : 56
Student Name: Abhay Manik Uchit.
-----------------------------------------------------------------------------------------------------------------
----------
Program:
Module Module1
Sub Main()
' Attempt to divide two numbers and handle potential exceptions.
Try
Console.Write("Enter the numerator: ")
Dim numerator As Integer = Convert.ToInt32(Console.ReadLine())

Console.Write("Enter the denominator: ")


Dim denominator As Integer = Convert.ToInt32(Console.ReadLine())

' Perform division


Dim result As Integer = numerator / denominator

Console.WriteLine("Result: " & result)


Catch ex As DivideByZeroException
' Handle division by zero
Console.WriteLine("Error: Cannot divide by zero.")
Catch ex As Exception
' Handle any other unexpected exceptions
Console.WriteLine("An unexpected error occurred: " & ex.Message)
Finally
' This block runs regardless of whether an exception was thrown.
Console.WriteLine("Operation completed.")
End Try

Console.ReadLine() ' Wait for user input before closing.


End Sub
End Module

Output :

You might also like