I have a piece of code that will be used by 18 different forms. Can someone post a quick example of how and ware i would put the code in only one place so all forms can call it.
Thanks
Printable View
I have a piece of code that will be used by 18 different forms. Can someone post a quick example of how and ware i would put the code in only one place so all forms can call it.
Thanks
Why not place your code in a module and have each form call it.
Mega.
That is what I want to do, but I have never done that. I just wanted a quick example of how to set it up and what the command is to call it. Thats all
Thanks
In a module, you can define subs and functions like this:
{The examples are meant for illustration only}
Public Function YourFunctionName(ByVal hwnd3 As Long, ByVal lParam As Long) As Long
..............
End Function
Or,
Public Sub ....
....
End Sub
The above can be called from any form, no problem.
Now, you can do the same on a forms code area,
and when you want to use it from another form,
Just reference its parents form, followed by a period, then the function or sub name.
ie....
Call Form1.MySubName
:) :) :)
-Hope this Helps
-Lou
Create a new module in your project and we will call it modFormcode
In the modules code type the following
Public sub frmEvent()
.....code goes here...
End sub
Then in the forms event that you want to trigger just place the command
frmEvent and that will pass control to the module. When the module has finished, control will be passed back to the form.
Mega.