April 2002
Intermediate to advanced
688 pages
19h 51m
English
Throw Statement
Throw exceptionexception (required; an Exception object or an object derived from Exception)An Exception object representing the exception being thrown
Throws an exception that can be handled using either structured
exception handling (a Try . . .
Catch block) or unstructured exception handling
(the On Error statement)
Try
' Ask for a positive number
Dim DataCt As Integer = CInt(InputBox("Enter number of items."))
' Check for error
If DataCt <= 0 Then
' Throw an exception
Throw New Exception("Must enter a positive number.")
End If
Catch ex As Exception
MsgBox(ex.Message)
End TryThe Throw statement is new to VB.NET.