Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Initialization
Hi,
What is the procedure to initliaze a variable as soon as the a macro is invoked. The variable and its value, thus initialized, needs to be accessible to other macros and procedures being executed in sequence thereafter. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Initialization
See 'Public Statement' in VBA help file.
" wrote: Hi, What is the procedure to initliaze a variable as soon as the a macro is invoked. The variable and its value, thus initialized, needs to be accessible to other macros and procedures being executed in sequence thereafter. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Initialization
There are 2 ways to make variable accessable to other procedure. One is to
declare the variable globally. While this seems like a good way to go you can end up with a project that is very difficult to maintain. A better way to make a variable accessabel to another procedure is to pass it to that procedure. 1 - Global Example dim str as string sub MainStuff() str = "this" call OtherStuff end sub sub OtherStuff str = str & " and that" msgbox str end sub 2 - Passing Example sub MainStuff() dim str as string str = "this" call OtherStuff(str) end sub sub OtherStuff(byval str as string) str = str & " and that" msgbox str end sub -- HTH... Jim Thomlinson " wrote: Hi, What is the procedure to initliaze a variable as soon as the a macro is invoked. The variable and its value, thus initialized, needs to be accessible to other macros and procedures being executed in sequence thereafter. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UserForm Initialization | Excel Programming | |||
Conditional Initialization | Excel Programming | |||
Userform Initialization | Excel Programming | |||
List box initialization | Excel Programming | |||
List box initialization | Excel Programming |