VB.Net by API/Microsoft.VisualBasic/Err — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:49, 26 мая 2010
Err.Number
Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim X As Integer
" Try to calculate X.
On Error Resume Next
X = CalculateValue()
Select Case Err.Number
Case 0 " No error. Do nothing.
Case 11 " Divide by zero. Set a default value.
X = 1000
Case Else " Unexpected error. Tell the user.
Console.WriteLine("Error calculating X." & vbCrLf & Err.Description)
Exit Sub
End Select
Console.WriteLine("X = " & X)
End Sub
Shared Private Function CalculateValue() As Integer
Return 1 \ Integer.Parse("0")
End Function
End Class