Search code examples
vb6stack-overflowruntime-error

Will "Out of stack space" error be trapped by error handler?


Will an "Out of stack space" error be trapped by the VB6 error handler, or will it always result in a run-time error?


Solution

  • It will be trapped by the error handler.

    Private Sub Form_Load()
      Count2 0
    End Sub
    
    Private Sub Count2(ByVal Value As Long)
      On Error GoTo x
      Count2 Value + 1
      Exit Sub
    x:
      MsgBox "stack depth " & Value
      Err.Clear
    End Sub
    

    stack depth 3659