Posted to microsoft.public.excel.programming
|
|
Declarations variables, Dim, some guidance please
Absolutely the same as a constant. Many thanks. I'm changing the code now.
you have helped me knock out about 40% of the declared vars.
--
Neal Z
"Bob Phillips" wrote:
Neal,
"Neal Zimm" wrote in message
...
Thanks to all for the sound advice, I hope y'all don't mind a common
response.
I'm relatively new to the VB game, self taught (with help from this
bulletin
board)
, and there's LOTS I don't know. (see later class variables.)
My uses of 'declared' vars in most cases, fall into all of the categories
mentioned.
1. vars where the values DON'T change, but are used by many subs. My
application is called "RM" and
I have a sub called zRM_Values which is called at the begining of larger
macros. (BTW, I have a bad
right pinky finger and typing quotes "" is a bother)
2 examples:
declared: dim Yes as string
in the zrm_values sub, Yes = "Y" , so in any other macro: if
other_var_name = yes then .....
declared: dim PressEnter as string
in zrm_values: PressEnter = "Press Enter or click OK after typing.." &
vbcr
' used in inputbox dialogs
This sound more like a constant than a variable
Const Yes As String = "Y"
declared and initialised in one statemenmt
2. I have tried mightily to have the module declared vars fall into two
other categories:
a) they have the same meaning in any macro in the module so
if the value is changed, it's kinda a good thing for me that other macros
have access to the 'latest' value.
b) I don't care if the value changes.
example: dim x as integer
since I use option explicit, without dim'ing x in every procedure,
I can use: for x = 1 to whatever
3. I have not learned what a "class with properties" is yet, nor
what a collection class is. Is the Excel help adequate on this topic
or can you recommend other reading sources?
I would suggest at this stage you don't bother with classes. Whilst they are
useful, they are rarely an absolute necessity. My point was really at Dave's
statement.
|