Select Case Err.Number : On Error GoTo « Statements « VB.Net Tutorial






Imports System.IO

public class Tester
   public Shared Sub Main

        On Error GoTo ErrorHandle
        Exit Sub

        ErrorHandle:
        Select Case Err.Number
            Case 52
                Console.WriteLine("File Name Exception")
            Case 53
                Console.WriteLine("File cannot be found")
            Case 54
                Console.WriteLine("File Mode Exception")
            Case 55
                Console.WriteLine("File is aleady open")
            Case 58
                Console.WriteLine("File exists")
            Case 68
                Console.WriteLine("Device is not available")
            Case 75
                Console.WriteLine("Path Exception")
            Case 76
                Console.WriteLine("Path cannot be found")
            Case Else
                Console.WriteLine("Other")
        End Select

   End Sub
   
End class








4.18.On Error GoTo
4.18.1.On Error GoTo errorhandle
4.18.2.Select Case Err.Number