public function

How can I create a public object function, that all the forms will recognize the function ???
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Put the function in a MODULE and declare it like this:

Public Function Twice(t As String) As String
  Twice = t & t
End Function

Ture Magnusson
Karlstad, Sweden
Place the function in a module(.bas file).  To create a new module right click in the project explorer and add a new module.
insert a module. say if you have a module named Main.bas

inside that module you define ur function ;

public function GlobalFunc()
'do ur stuff here
end function

it'll be able to call from any form..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

lirongAuthor Commented:
But the the function is using an object
(such as MCIcontrol), and when I placed it in the class module I got an error...

What was your error?

How was your "answer" different from the comments above?
If you want something like the App object or the Debug object, you need to create an ActiveX DLL.

Here's how:

- Create an ActiveX DLL project.
- Add a class and set it's Instancing property to "GlobalMultiUse"
- Add the Public Function (method) that you need to call anywhere in your form.
- Create the DLL.
- Reference the DLL in your project and you can now call the public function that you created.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.