VB.Net Tutorial/Statements/On Error GoTo — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:53, 26 мая 2010
On Error GoTo errorhandle
Imports System.IO
public class Tester
public Shared Sub Main
Dim myfile As System.IO.File
Dim w As System.IO.StreamWriter
On Error GoTo errorhandle
w = myfile.AppendText("a:\temp.txt")
w.Write("a")
w.Close()
Exit Sub
errorhandle:
Console.WriteLine("Please Insert")
Exit Sub
Resume
End Sub
End class
Please Insert
Select Case Err.Number
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