-
I dont really understand this and
I was hoping someone could explain
this to me.
For the use through all of my form
I would declare a variable "Public".
It seems to work fine! Whats the
point of declare a variable "Global".
Besides Private, Dim, Public, And
Global are there any other ways to
declare variables?
thanks!
-
No point to use Global since Public does the same, it's for backward compability, Private variables can also be declared with Dim, can't be accessed from outside that module. Dim is used mostly to declare variables with procedure scope, you declare them inside a function or sub, Also there's static variables which you declare static within a procedure. Their values will remain when you exit the function and not be instanced everytime you call it. Can be usefull sometimes for recursion.
-
Thanks..
Sounds like all you need is Private
and public.
Whats the point in using static,
or global!
Static if im correct will stay in
memory as long at the program is
running right? So why not just use
a public?
-
Global was used in earlier versions of VB but was replaced by Public in VB4.
The only reason Global is still around is so that you can load previous VB projects into newver VB projects.
(called backwards compatibility)
-
Static variables won't be initialized until the line is fired. It will unload if the object it exist in unloads.
Static variables are also declared at procedure level so you won't need to put it topmost, also use private instead of public as often as you can, that will save you performance.
Also, in fact, it's Dim and Public not Private and public that is the only ones you actually need.