I have a VB6 program which I've been maintaining for ten years. There is a subroutine in the program called "Prepare Copy", which looks like this (Edited to add changes):
Public Sub PrepareCopy()
On Local Error GoTo PrepareCopyError
MsgBox "in modeldescription preparecopy"
Set CopiedShapes = New Collection
MsgBox "leaving preparecopy"
Exit Sub
PrepareCopyError:
MsgBox Err.Description, , Err.Number
Resume Next
End Sub
Where CopiedShapes
is dimmed out as a VB6 Collection.
That code is now kicking out a Runtime Error 5 -- Invalid Procedure Call or Argument. It appears from the interstitial debugging code that the error arises between the MsgBox "in modeldescription preparecopy"
and the MsgBox "leaving preparecopy"
lines, and that the On Error
code path never executes.
Once the Error 5 dialog box is cleared, then the MsgBox "leaving preparecopy"
dialog appears, after which the program closes out.
It's behaving this way on my development machine and two client computers.
It is only happening in runtime code, and does not appear to make a difference whether I compile it or use P-Code
What I'm asking for here is speculation as to what causes this sort of thing to happen.