vreid

How and where to use Private or Public sub, function, variables

Discussion created by vreid on Jan 27, 2011
Latest reply on Jan 31, 2011 by rwelikal
In one of the courses I'm taking, it talks about Private and Public subs, functions and variables. I understand the definition of Private of Public, but it does not clearly specify to me when and where to use them. 

Can Private and Public (variable, sub, and/or function) be used in the same Module? 

Does it matter what kind of Module it is? (Form, Standard, ThisDocument, Class Module)

Or where the variable is declared.  Can you have a Variable declared as Public in General Declaration, but then use it in a Private Sub or Function - and viceversa?

Also, examples have procedures that start with Sub or Functions, but no Private or Public.  Are they automatically Private?

I'm also confused as to when you use a Sub instead of a Function.  The examples do not make it clear to me at all.

Outcomes