Calling Procedures in Other Modules


Procedures in other modules can be called from anywhere in the project. You might need to specify the module that contains the procedure you’re calling. The techniques for doing this vary, depending on whether the procedure is located in a Form, class, or standard module.

Ø Procedures in Forms

All calls from outside the Form module must point to the Form module containing the procedure. If a procedure named SomeSub is in a Form module called Form1, then you can call the procedure in Form1 by using this statement:

Call Form1.SomeSub(arguments)

To call the procedure in a different instance (or copy) of a Form, use the variable that points to the instance to qualify the procedure name. The following code calls the SomeSub procedure contained in DemoForm, which is an instance of Form1.

Dim DemoForm As New Form1

DemoForm.SomeSub(arguments) ' Where DemoForm is an instance of Form1.

No comments:

Post a Comment