Ejercicio
Excepciones
Objetivo
Cree un programa en Visual Basic para solicitar al usuario dos números y mostrar su división. Los errores deben ser capturados utilizando "try..catch".
Código
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