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