VK LABELS

Sunday, 16 March 2014

Handle Devide by Zero Exception in VB.Net Console Applications

HANDLE DEVIDE BY ZERO EXCEPTION:
  • Type this program in Visual Basic Console Application.


Module Module1
    Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
        Dim result As Long
        Try
            result = num1 \ num2
        Catch e As DivideByZeroException
            Console.WriteLine("Exception caught: {0}", e)
        Finally
            Console.WriteLine("Result: {0}", result)
        End Try
    End Sub
    Sub Main()
        Dim a, b As Long
        Console.WriteLine("Division Program")
        Console.WriteLine("Type First Value:")
        a = Console.ReadLine
        Console.WriteLine("Type Second Values:")
        b = Console.ReadLine
        division(a, b)
        Console.ReadKey()
    End Sub

End Module

No comments:

Post a Comment