
How to call a form routine from a module by the form handle
Quote:
>I have two form files, each contains a procedure called "MyProc". I
>also have a module, from where I want to call MyProc either in Form1
>or Form 2, depending on a var where I store the destination form's
>handle. It looks like this:
>If lngHandle = Form1.hwnd Then
> Call Form1.MyProc
>Else If lngHandle = Form2.hwnd Then
> Call Form2.MyProc
>End If
>The problem is, that I have to test for each form handle in the module
>and that I cannot write a general module to use in more projects
>because it has to be changed for each project.
>The best idea would be to do something like "Call lngHandle.MyProc",
>but that does not work.
One approach would be to put a hidden button on each form, pass the button to
the module, and later invoke its Click event by setting its Value. For
example:
Private cmdCallback as CommandButton
Public Sub SetCallback(cmd as CommandButton)
Set cmdCallback=cmd
End Sub
Public Sub DoCallback
cmdCallback=True
End Sub
J. Bodie