Exception Handling using VB.NET
In this small article you will learn how to use Exception Handling in visual Basic.NET
Exception handling is a technique of handling a situation which is occur at the run time when program abort without execution and the cause of that situation is called exception.
Exception can be handled by two ways in VB.NET .
1.Structured exception handling.
2. Unstructured exception handling.
Hear I am going to tell about the structured exception handling using : Tryâ€¦.Catchâ€¦.Finally.
Dim a = 0, b = 1, c As Integer
c = b / a
Console.WriteLine("C is " & c)
Catch e As Exception
Console.WriteLine("0 can't be divided by any number")
In this code a numbers divided by zero which result is infinity. This error is thrown by Try Block and Catch block shows the exception after catching it.
This example helps you to understand how exception occurs than thrown and than catch and shows the exception at the run time.