Thread: Dim vs. Public
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jamie Collins Jamie Collins is offline
external usenet poster
 
Posts: 593
Default Dim vs. Public


Harald Staff wrote:
I use public variables for things that are used
all over the app and that won't change "today" (=during the session).
Typically it's a username, a database address, environmental

information, a
major choice in startup, ...


I can see a justification in these cases because they are genuinely
global to the project/session in question. Such measured thought is not
always present. I was recently tempted in an Excel project to use a
Public variable named IsDirty but when I stopped to think about it, I
concluded it was specifically the *workbook* I was flagging as dirty,
therefore I ended up creating a Friend Property in the ThisWorkbook
code module.

Question of style, I think.


At the level being discussed here, definitely. To use all Public
variables declared as Variant may be a 'dubious' style <g.
Jamie.

--