vb6exceptionsehstructured-exception

How to implement SEH (Structured Exception Handling) in VB6?


Could someone provide some example on implementing SEH in VB6? Everything I've seen so far is in C++


Solution

  • Visual Basic 6.0 (and earlier) doesn't implement structured exception handling. It was first introduced in Visual Basic .NET (VB 7) with the following construct:

    Try
        ' Logic
    Catch e As Exception
        ' Error handling
    End Try
    

    From the MSDN documentation:

    In Visual Basic 6.0, you use unstructured exception handling to deal with errors in your code. Placing the On Error statement at the beginning of a block of code handles any errors that occur within that block. Unstructured exception handling also employs the Error and Resume statements.