2

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

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
cfischer
  • 24,452
  • 37
  • 131
  • 214
  • You can still do a lot in VB6 to handle errors. What exactly are you trying to achieve? – CResults Mar 22 '10 at 16:42
  • Handle an access violation caused by a third party component on exit. – cfischer Mar 22 '10 at 16:47
  • "Access violation" is different from "Structured exception handling". You can't handle an "access violation" with VB6 error handling, nor C++ structured exception handling, nor yet with VB.Net Try...Catch structured exception handling. You need to report a bug to the vendor of the 3rd party component. – MarkJ Mar 23 '10 at 13:41

1 Answers1

1

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.

Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154