Use of Exception Handling in VB.NET

In this article we will learn how to use exception handling in VB.NET.
  • 1755

In general we use try/catch for Exception Handling. Exception handling is use to secure our code. for Example whenever we ride a bike we may use the helmet.

An Exception may happen anytime during the execution of a code So we always prepare to handle such a situation.

We Use Try/Catch keywords to handle the exception

try
{
// Code which can cause an exception.
}
catch (Exception ex)
{
// Code to handle exception
}
 
we can also use the "finally" block for exception handling

try
{
// Code which can cause an exception.
}
catch (Exception ex)
{
// Code to handle exception
}

finally
{
//
}
 
The "finally" block is executed surely whenever an exception occur.
 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.