Throwing an Exception in VB.net
By: Steven Holzner
You can throw an exception using the Throw statement, and you can also rethrow a caught exception using the Throw statement. Here's an example where I'm explicitly throwing an overflow exception:
Module Module1
Sub Main()
Try
Throw New OverflowException()
Catch e As Exception
System.Console.WriteLine(e.Message)
End Try
End Sub
End Module
Tip |
In fact, it's even possible to mix structured and unstructured exception handling to some extent—if you're using unstructured exception handling, you can get an exception object with the Err object's GetException method and throw that exception in a Try block. |
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net