Hi guys,
I read quite a few threads here and i don quite understand the relationship btw Modules and forms and how it affect the declaration of a function.
Can somebody explain to me how it works?
Printable View
Hi guys,
I read quite a few threads here and i don quite understand the relationship btw Modules and forms and how it affect the declaration of a function.
Can somebody explain to me how it works?
i'm not an expert but i think the difference is that when you write a function in a form it is limited to that form and project that you are making
if you use a module than you can add it to any project and access the code to it ... therefore you aren't limited ???
the idea of a module is to be accessible to all forms...
in a normal form the double-clicking on a button will create:
Private sub command1_click()
end sub
notice the word..."private"...that mean that this specific sub\function is accessible only through this specific form
if you change the "private" to "public" then this sub\function will be accessible through all forms or modules
about modules :
a module will usually contain function called "Public"...
that's because the module is kinda global function library..
though...you can rename functions in a module as "Private" if you are intending to use it only in that specific module (could be in order to help other function in that module
Forms can contain controls, and recieve events during to window messages sent to the window that is the form. Modules don't need to be accessed by their name. That's the most important differences.