View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rick is offline
external usenet poster
 
Posts: 334
Default Declaring subs Public vs Private

Thank you all for the information: Now how should one construct the module?
What should be declared Private vs not declared at all, just sub name(parms)?

"Jim Thomlinson" wrote:

In addition to what everyone else has said there is a programming concept
called encapsulation. The underlying rule is to keep everything as private
and stand alone as possible. The more subs and variables you make public the
more things you need to consider when something goes wrong. By keeping things
private things stay a lot neater and tidier. It also makes things a lot
easier to modify down the road. For example if you wnat to modify a sub that
is private then you only need to look at the other subs in the same module to
see if your changes will cause a problem elsewhere. If however the same sub
was declared public then you need to look at all of the code in the entire
project to confirm that there is no conflict. That is a real waste of time if
you did not use the sub outisde of the current module.
--
HTH...

Jim Thomlinson


"Rick" wrote:

When is it correct to declare a sub Public vs Private? What is the advantage?