Exercise
Exceptions
Objetive
Write a Visual Basic (VB.Net) program to prompt the user for two numbers and display their division. Errors should be caught using "try..catch"
Code
Imports System
Public Class exercise48
Public Shared Sub Main()
Dim number1 As Integer
Dim number2 As Integer
Dim division As Integer
Console.Write("Enter a number to divide: ")
number1 = Convert.ToInt32(Console.ReadLine())
Console.Write("Enter another number to divide: ")
number2 = Convert.ToInt32(Console.ReadLine())
Try
division = number1 / number2
Console.WriteLine("{0} / {1} = {2}", number1, number2, division)
Catch __unusedDivideByZeroException1__ As DivideByZeroException
Console.WriteLine("Cannot divide by Zero")
Return
End Try
End Sub
End Class