The amazing error trap



  • Warning: Visual Basic 6 code ahead, do not read if of a nervous disposition.

    Just a little snippet of code I stumbled upon this week - everything as was, apart from the object name stuff (changed to protect the innocent and misguided) and the 'snips'......


    [code]'Snip

    Dim inErr



    On Error Goto LocalErrorTrap



    inErr = False



    If Not inErr Then Set objObjectName = CreateObject("ObjectName.ChangedHere")



    If inErr = False then
    '
    ' Snip - loads of code here
    '

    EndIf



    '

    ' Snip loads more code here (some of which happens to rely on the code in the if above)

    '



    Exit Sub



    LocalErrorTrap:



    inErr=True

    Resume Next

    Resume

    Return 'For completeness!



    End Sub[/code]



  • Visual Basic always makes my brain hurt; I am lucky to have survived reading this...thing.



  • You know how simple things sometimes elude comprehension by the human brain?

    This is one of those things.



  • @dhromed said:

    You know how simple things sometimes elude comprehension by the human brain?


    Vroomfondel: Now that's what I call thinking. How come we can't think like Majikthise?

    Majikthise: Maybe our minds are... too highly trained.



  • I understood that code and why it's a WTF (beyond being in VB).
    Does that mean that I'm a closet VB coder or something?



  • The real WTF is that the programmer... oh, wait! wrong forum.  Sorry.

         -dZ.



  • @Zlodo said:

    I understood that code and why it's a WTF (beyond being in VB).
    Does that mean that I'm a closet VB coder or something?


    Yes.

    Shall I get the hose?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.