On Error GoTo ... Resume Statement

αž’αŸ’αžœαžΎβ€‹αž²αŸ’αž™β€‹αž”αŸ’αžšαžΎβ€‹αž”αžΆαž“β€‹αž‘αž˜αŸ’αžšαž„αŸ‹β€‹αž€αžΆαžšβ€‹αž€αŸ†αž αž»αžŸ αž”αž“αŸ’αž‘αžΆαž”αŸ‹β€‹αž–αžΈβ€‹αž€αŸ†αž αž»αžŸβ€‹αž€αžΎαžβ€‹αž‘αžΎαž„ αž¬β€‹αž”αž“αŸ’αžβ€‹αž”αŸ’αžšαžαž·αž”αžαŸ’αžαž·β€‹αž€αž˜αŸ’αž˜αžœαž·αž’αžΈΒ αŸ”

Syntax:

On Error Statement diagram


On [Local] Error {GoTo Labelname | GoTo 0 | Resume Next}

Parameters:

GoTo Labelname αŸ– αž”αŸ’αžšαžŸαž·αž“β€‹αž”αžΎβ€‹αž€αŸ†αž αž»αžŸβ€‹αž€αžΎαžβ€‹αž‘αžΎαž„ αž’αŸ’αžœαžΎβ€‹αž²αŸ’αž™β€‹αž”αŸ’αžšαžΎβ€‹αž”αžΆαž“β€‹αž‘αž˜αŸ’αžšαž„αŸ‹β€‹αž€αžΆαžšβ€‹αžŠαŸ„αŸ‡αžŸαŸ’αžšαžΆαž™β€‹αž€αŸ†αž αž»αžŸ αžŠαŸ‚αž›β€‹αž…αžΆαž”αŸ‹αž•αŸ’αžαžΎαž˜β€‹αž“αŸ…β€‹αž”αž“αŸ’αž‘αžΆαžαŸ‹ "Labelname"Β αŸ”

Resume Next αŸ– αž”αŸ’αžšαžŸαž·αž“β€‹αž”αžΎβ€‹αž€αŸ†αž αž»αžŸβ€‹αž€αžΎαžβ€‹αž‘αžΎαž„ αžŠαŸ†αžŽαžΎαžšαž€αžΆαžšβ€‹αž”αŸ’αžšαžαž·αž”αžαŸ’αžαž·β€‹αž€αž˜αŸ’αž˜αžœαž·αž’αžΈβ€‹αž”αž“αŸ’αžβ€‹αž‡αžΆαž˜αž½αž™β€‹αžŸαŸαž…αž€αŸ’αžαžΈβ€‹αžαŸ’αž›αŸ‚αž„β€‹αž€αžΆαžšαžŽαŸ αžŠαŸ‚αž›β€‹αž“αŸ…β€‹αž”αž“αŸ’αžβ€‹αž–αžΈβ€‹αžŸαŸαž…αž€αŸ’αžαžΈβ€‹αžαŸ’αž›αŸ‚αž„β€‹αž€αžΆαžšαžŽαŸ αžŠαŸ‚αž›β€‹αž€αŸ†αž αž»αžŸβ€‹αž”αžΆαž“β€‹αž€αžΎαžβ€‹αž‘αžΎαž„Β αŸ”

GoTo 0: αž”αž·αž‘β€‹αž€αž˜αŸ’αž˜β€‹αžœαž·αž’αžΈβ€‹αžŠαŸ„αŸ‡αžŸαŸ’αžšαžΆαž™β€‹αž€αŸ†αž αž»αžŸβ€‹β€‹αž€αŸ’αž“αž»αž„β€‹αž”αŸ‚αž”αž”αž‘β€‹αž”αž…αŸ’αž…αž»αž”αŸ’αž”αž“αŸ’αž“β€‹ αŸ”β€‹

αž˜αžΌαž›αžŠαŸ’αž‹αžΆαž“Β αŸ– "αž“αŸ…β€‹αž–αŸαž›β€‹αž˜αžΆαž“β€‹αž€αŸ†αž αž»αžŸ" αž‚αžΊβ€‹αž‡αžΆβ€‹αž€αŸ†αž αž»αžŸβ€‹αžŸαž€αž›β€‹αž“αŸ…β€‹αž€αŸ’αž“αž»αž„β€‹αžœαž·αžŸαžΆαž›β€‹αž—αžΆαž– αž αžΎαž™β€‹αž“αŸ…αžαŸ‚β€‹αžŸαž€αž˜αŸ’αž˜β€‹αžšαž αžΌαžβ€‹αžŠαž›αŸ‹β€‹αž”αžΆαž“β€‹αž”αŸ„αŸ‡αž”αž„αŸ‹β€‹αžŠαŸ„αž™β€‹αžƒαŸ’αž›αžΆαž„ "αž“αŸ…αž–αŸαž›β€‹αž˜αžΆαž“αž€αŸ†αž αž»αžŸ" αž•αŸ’αžŸαŸαž„β€‹αž‘αŸ€αžΒ αŸ”"αž“αŸ…αž–αŸαž›β€‹αž˜αžΆαž“β€‹αž€αŸ†αž αž»αžŸβ€‹αž˜αžΌαž›αžŠαŸ’αž‹αžΆαž“" αž‚αžΊβ€‹αž‡αžΆβ€‹αž€αŸ†αž αž»αžŸβ€‹αž˜αžΌαž›αžŠαŸ’αž‹αžΆαž“β€‹αžŠαžŠαŸ‚αž›β€‹αžŠαŸ‚αž›β€‹β€‹αž αŸ…β€‹αžœαžΆβ€‹αž…αŸαž‰Β αŸ” αž€αŸ†αž αž»αžŸβ€‹αž˜αžΌαž›αžŠαŸ’αž‹αžΆαž“β€‹αžŠαŸ„αŸ‡αžŸαŸ’αžšαžΆαž™β€‹αž€αžΆαžšβ€‹αž”αžŠαž·αžŸαŸαž’β€‹αž€αžΆαžšβ€‹αž€αŸ†αžŽαžαŸ‹β€‹αžŸαž€αž›αžŽαžΆαž˜αž½αž™Β αŸ” αž“αŸ…αž–αŸαž›β€‹β€‹αž αŸ…β€‹αž€αžΆαžšβ€‹αž…αŸαž‰β€‹αžŠαžŠαŸ‚αž› αž€αžΆαžšβ€‹αžŠαŸ„αŸ‡αžŸαŸ’αžšαžΆαž™β€‹αž€αŸ†αž αž»αžŸβ€‹αž˜αžΌαž›αžŠαŸ’αž‹αžΆαž“β€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“αž”αŸ„αŸ‡αž”αž„αŸ‹β€‹αžŠαŸ„αž™β€‹αžŸαŸ’αžœαŸαž™β€‹αž”αŸ’αžšαžœαžαŸ’αžαž· αž αžΎαž™β€‹αž€αžΆαžšαž€αŸ†αžŽαžαŸ‹β€‹αžŸαž€αž›β€‹αž–αžΈαž˜αž»αž“β€‹αžŽαžΆαž˜αž½αž™β€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αžŸαŸ’αžŠαžΆαžšβ€‹αž‘αžΎαž„β€‹αžœαž·αž‰Β αŸ”

αžƒαŸ’αž›αžΆ On Error GoTo αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αž”αŸ’αžšαžΎβ€‹αžŠαžΎαž˜αŸ’αž”αžΈβ€‹αž†αŸ’αž›αžΎαž™αžαž”β€‹αž‘αŸ…β€‹αž“αžΉαž„β€‹αž€αŸ†αž αž»αžŸβ€‹αžŠαŸ‚αž›β€‹αž€αžΎαžαž‘αžΎαž„β€‹αž“αŸ…β€‹αž€αŸ’αž“αž»αž„β€‹αž˜αŸ‰αžΆαž€αŸ’αžšαžΌ αŸ”

Example:


Sub ExampleReset
On Error GoTo ErrorHandler
    Dim iNumber As Integer
    Dim iCount As Integer
    Dim sLine As String
    Dim aFile As String
    aFile = "C:\Users\ThisUser\data.txt"
    iNumber = Freefile
    Open aFile For Output As #iNumber
    Print #iNumber, "This is a line of text"
    Close #iNumber
    iNumber = Freefile
    Open aFile For Input As iNumber
    For iCount = 1 To 5
        Line Input #iNumber, sLine
        If sLine <>"" Then
            Rem
        End If
    Next iCount
    Close #iNumber
    Exit Sub
ErrorHandler:
    Reset
    MsgBox "All files will be closed",  0,  "Error"
End Sub

Please support us!