Hi
I've never been a complete genius at this but...
Local variable - available only to the routine
Sub Proc()
Dim var as Range
'do stuff
End Sub
Module (or Private) variables are declared outside the subs but within the module using either the Dim or Priavate statements
Dim var as integer
Sub Proc()
var = 1
End Sub
Sub Proc2()
var = 100
End Sub
Public as above but variable is available to all modules in a project. Can also be used in class modules but that's definately beyond me! COM and such things!!
Check out the help files for Dim, Private, Friend & Public keywords, maybe also Static & Const Data types will probably be roughly the same as with C++ (integer, long, double, boolean etc
You should also look into "Option Explicit" I don't know C++ but I am aware that VB/VBA is quite forgiving in ways that can lead to problems, ie you don't actually have to declare variables. Option Explicit will force variable declaration. It sits at the top of each module and can be set thru options or something but I can't remember the exact route to it.
Hope this helps
;-)
If a man says something and there are no women there to hear him, is he still wrong?
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.