On Error Resume Next : Err Number « Development « VB.Net






On Error Resume Next

On Error Resume Next
Imports System

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        On Error Resume Next
        DoSomething()
        If Err.Number <> 0 Then
            Console.WriteLine("Error in DoSomething")
            Exit Sub
        End If

        DoSomethingElse()
        If Err.Number <> 0 Then
            Console.WriteLine("Error in DoSomethingElse")
            Exit Sub
        End If

    End Sub
    Shared Private Sub DoSomething()
            Throw New ArgumentException("Error in subroutine DoSomething")
    End Sub
    Shared Private Sub DoSomethingElse()
            Throw New ArgumentException("Error in subroutine DoSomethingElse")
    End Sub

End Class

           
       








Related examples in the same category

1.Check Err.Number When there is an ErrorCheck Err.Number When there is an Error