????? ??????? ????????? ????? ?????? ?? Visual Basic.net ?? ?? Visual Basic 2005

?????? ????????? ?????? ?????????
???? ???????: 315965 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ?????? ????? ??????? ????????? ?????? ??.net Visual Basic ?? Visual Basic 2005.

???????

???? ??????? ??????? ??????? ?????? ???? ???????? ??????? ???????? ?????? ???? ??????? ???? ???????:
  • Visual Basic.net ?? Visual Basic 2005
????? ??? ??????? ??? ????? ?? ???????? ???????:
  • Visual Basic.net ?? Visual Basic 2005
  • Microsoft Visual Studio.net ?? Microsoft Visual Studio 2005

?????? ????????? ?????

.NET Visual Basic ?? Visual Basic 2005 ???? ?????? ????????? ??????? ???? ???? ?????? ???? ????? ?????? ??????? ??????? ??????? "On Goto ???"? ???? ????? ?? ????????? ??????? ?? Microsoft Visual Basic. ?????? ????????? ????? ???? ???? ???? ???? ?????? ??????? ????? ???? ??????? ????? ???? ???? ??? ???????. ????? ??? ???? ?????? ?????? ????????? ????? ???? ???? ???? ?????? ???...???...??? ??????. ??? ???? ????????? ???????? ? visual Basic.net ? 2005 Visual Basic ???? ?????? ??????? ???????? ????.

??????: Visual Basic.net ?? Visual Basic 2005 ????? ???? ?????? "On Goto ???" ?? ??? ??????? ?? ????????? ???????. ?? ???? ????? ??????? ???? ?????? ?? ????????? ???????? ? visual Basic.net ?? 2005 Visual Basic. ??? ???? ?? ????? ??? ?????? ????????? ??????? ???? On Error ???? ??? ???????. ??? ????? ??? ????? ???? Microsoft ???????? ???? ?????? ?????????.

???? ?????? ??????? ??????? ????? ????? ??? ???:
Try
   'Code that may raise an error.
Catch
   'Code to handle the error.
Finally
   'Code to do any final clean up.
End Try
				
?????? ???? ? ???? ????? ??????. ?????? Catch ? ????? ??? ??????? ??? ????? ?? ??? ???? ????? ???? ??? ????? ?? ????????? ???????? ?????? ??. ????? ???? ????? ??? ?????? Catch ??? ?? ?? ???? Catch ?????? ??? ????.

?????? ???????

  1. ??? ????? ?????? Visual Studio.net ?? Visual Studio 2005.
  2. ????? ????? "????? ???? ????" ???? ?? Visual Basic.net ?? ?? Visual Basic 2005.
  3. ?? ????? Sub Main ? ??? ????????? ???????? ???????:
    Dim a As Integer = 0
    Dim b As Integer = 0
    Dim c As Integer = 0
    
    Try
      a = b \ c
    Catch exc As Exception
      Console.WriteLine("A run-time error occurred")
    Finally
      Console.ReadLine()
    End Try
    					
  4. ?? ??????? " ????? "? ???? ??? " ???? " ?????? ???????. ????? ???????? ???????? ???? ??? ??? ???. ??? ?? ????? ??? ??????? ???? ??? ???? ??? ??? ?????????. ???? ????? ???? Catch ???????? ??? ?????? ????? ???? ?????? ???? ????? ????? ???????:
    A run-time error has occurred
    						
  5. ????? ???? ???? ??????.

?????? ??????????? ??????

???? ??? ????? ????? ??????? ?????? ?????? ??? ??????? ??????? ??????.
  1. ???? ??????? "????? ???? ??????" ???? ??? ??????? ?? ?????? ??????.
  2. ?? ????? Sub Main ? ??????? ???????? ???????? ???? ??? ?????? ?? ?????? ?????? ?? ????????? ???????? ???????:
    Dim a As Integer = 2147483647
    Dim b As Integer = 0
    Dim c As Integer = 0
    
    Try
      a += 1
    Catch exc As DivideByZeroException
      Console.WriteLine("Error: Divide by zero")
    Catch exc As OverflowException
      Console.WriteLine("Error: Overflow")
    Finally
      Console.ReadLine()
    End Try
    						
    ??? ????????? ???????? ????? ??? Catch ?????: ???? ??????? ?????? ??????? ?? ???? ????? ??? ????? ?????? ??? ????? ????? ????.
  3. ?? ??????? " ????? "? ???? ??? " ???? " ?????? ???????. ???? ???? ???? ?????? ????? ????? ???????:
    Error: Overflow
    						
  4. ????? ???? ???? ??????.
  5. ??? ????? ?? ????? ?? ??? ???? ???? ?? ????? ????? ????? ???? ?????? ???? ????????? ??? ??????. ??? ???? ??????? ??? ????????? ???????? ??????? ??? ????? ????? ??????? ?? ????? ??? ?????? ???? ????? ????? ???????:
    Catch exc As Exception
    Console.WriteLine("Error: " & exc.Message)
    					
  6. ?? ??????? ??? ? ???? ??? ???? ?????.

?? ???? ???????

?????? ?????? ????????? ????? ????? Catch ??????? ???????. ?????? ????????? ??? ???? ????? ????? ???? ???????. ??? ???? ??????? ???? ?? ?????? ?? ???? ??????? ??? ????? ?????? ?? ??? ???????? ???? ????? ????? ??????? ???? ?? ???? ?? ??? ??? ??? ??? ????? ???.
  1. ??? ????? ?????? Visual Studio.net ?? Visual Studio 2005.
  2. ????? ????? "????? ???? ????" ???? ?? Visual Basic.net ?? ?? Visual Basic 2005.
  3. ?? ??????? ??????? ???? ??? ????? ???.
  4. ?? ?????? " ????? ???? ???? "? ???? clsPerson.vb ?? ?? ??? ???? ??? ?? ???? ??? ?????.
  5. ????? ???????? ???????? ??????? ???? clsPerson "?????? ??????"...????? ??? ????????:
    Private mintAge As Integer
    
    Public Property Age() As Integer
      Get
        Age = mintAge
      End Get
      Set(ByVal Value As Integer)
        If Value >= 0 Then
          mintAge = Value
        Else
          Throw New ArgumentException ("Age cannot be negative")
        End If
      End Set
    End Property
    						
    ???? ??? ????? ??? ????? ????? . ???? ?? ???? ?? ???? ??? ??? ?????? ???? ??? ??? ???? ?????? ????? ?????? ????? ??? ??? ??? ?? ?????.
  6. ?? ????? Sub Main ?? Module1.vb? ??? ????????? ???????? ???????:
    Dim p As New clsPerson()
    
    Try
      p.Age = -1
    Catch exc As Exception
      Console.WriteLine(exc.Message)
    Finally
      Console.ReadLine()
    End Try
    					
  7. ?? ??????? " ????? "? ???? ??? " ???? " ?????? ???????. ???? ???? ???? ?????? ????? ????? ???????:
    Age cannot be negative
    						
  8. ????? ???? ???? ??????.

????? ??? ????????? ????????

?????? ???????

Module Module1

  Sub Main()
    Dim a As Integer = 0
    Dim b As Integer = 0
    Dim c As Integer = 0

    Try
      a = b \ c
    Catch exc As Exception
      Console.WriteLine("A run-time error occurred")
    Finally
      Console.ReadLine()
    End Try

  End Sub

End Module
				

?????? ??????????? ??????

Module Module1

  Sub Main()
    Dim a As Integer = 2147483647
    Dim b As Integer = 0
    Dim c As Integer = 0

    Try
      a += 1
    Catch exc As DivideByZeroException
      Console.WriteLine("Error: Divide by zero")
    Catch exc As OverflowException
      Console.WriteLine("Error: Overflow")
    Catch exc As Exception
      Console.WriteLine("Error: " & exc.Message)
    Finally
      Console.ReadLine()
    End Try


  End Sub

End Module
				

?? ???? ???????

Module Module1

  Sub Main()
    Dim p As New clsPerson()

    Try
      p.Age = -1
    Catch exc As Exception
      Console.WriteLine(exc.Message)
    Finally
      Console.ReadLine()
    End Try
  End Sub

End Module

Public Class clsPerson

  Private mintAge As Integer

  Public Property Age() As Integer
    Get
      Age = mintAge
    End Get
    Set(ByVal Value As Integer)
      If Value >= 0 Then
        mintAge = Value
      Else
        Throw New ApplicationException("Age cannot be negative")
      End If
    End Set
  End Property

End Class
				

?????

????? ?? ?????????? ???? ??? ????? Microsoft ??????? ??? ?????:
??? ?? ?????? ????? VB.NET: ???????? ???????????? (???? ???? Visual Basic )
.aspx http://msdn.microsoft.com/en-us/library/aa227603 (v=vs.60)

????? ?????? ???????
.aspx http://msdn.microsoft.com/en-us/library/ys1b32h3 (v=vs.80)

??? ??? ???????
.aspx http://msdn.microsoft.com/en-us/library/z7w9ff54 (v=vs.80)

???????

???? ???????: 315965 - ????? ??? ??????: 25/???/1433 - ??????: 2.0
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbvs2005swept kbvs2005applies kbhowtomaster kbmt KB315965 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????315965

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com