ARTICLE

Exception Handling in VB.NET

Posted by Brijesh Jalan Articles | Visual Basic 2010 July 16, 2010
In this article we will learn how to use exception handling in VB.NET.
 
Reader Level:


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.
 

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Diagram
Become a Sponsor