Hello There
Trying to learn Access the difficult way ( by myself)
I used to use dbase 4 ver 2 (dos)
Can someone tell me if "option explicit" in VBA is the same thing as we called "private"
in dbase?
thanks
fred
Hello There
Trying to learn Access the difficult way ( by myself)
I used to use dbase 4 ver 2 (dos)
Can someone tell me if "option explicit" in VBA is the same thing as we called "private"
in dbase?
thanks
fred
option explicit : means you MUST define your variables,
Dim i as integer
dim sTxt as string
ALWAYS use this. Its good for finding mistakes.
If you dont use it and you mistype a variable, sTxr = "bob"
your results can come out wrong, since the code is looking for sTxt.
Explicit will alert you to this.
PRIVATE , is like Dim but for the entire module.
dim is for a single subroutine or function
the module holds all the subroutines and the variable declared here can be seen by ALL subs in the module.
a form has a module code.
(note I cannot use the 'code' flag here...the website keeps messing it up)
Private msName as string
sub btnGo_click()
dim i as integer
msgbox msName
end sub
sub btnStop_click()
msgbox msName
end sub
in the code above, msName can be seen by all subs.
but the i in btnGo_click can ONLY be seen by btnGo_click
and other modules cannot see module level variables.
but all modules can see Public vars.
dim (for subs)
private (for modules)
public (for everything, global)