Programming Tutorials

Using On Error GoTo 0 in

By: Steven Holzner in Tutorials on 2010-11-17  

To turn off unstructured exception handling, you can use the On Error GoTo 0 or On Error GoTo -1 statements. Here's an example:

Module Module1
    Sub Main()
        Dim int1 = 0, int2 = 1, int3 As Integer
        On Error Goto Handler
        int3 = int2 / int1
        On Error Goto 0  'Turn error handling off
        System.Console.WriteLine("Program completed...")
        If (TypeOf Err.GetException() Is OverflowException) Then
            System.Console.WriteLine("Overflow error!")
            Resume Next
        End If
    End Sub
End Module

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in )

Latest Articles (in