Alex Rivera | Logout

How to raise an exception in VB.NET

Asked 2012-10-31T04:34:11.180
56

How should an exception be raised in VB.NET?

Edit
Report

1 Answer

85

You would throw a new exception.

Have a look at Throw Statement (Visual Basic)

The Throw statement throws an exception that you can handle with structured exception-handling code (Try...Catch...Finally) or unstructured exception-handling code (On Error GoTo). You can use the Throw statement to trap errors within your code because Visual Basic moves up the call stack until it finds the appropriate exception-handling code.

EDIT

By request and from the link

Throw New System.Exception("An exception has occurred.")
answered 2012-10-31T04:36:11.783

Your Answer