Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I thought i had a good understanding of Scope and lifetime of varaibles but i'm havibg a problem. I need to maintain and update the value of variable for the life of of the running app. I decalred it as public in a module and I set its value in a Form module. It maintains its value as long as the first form is running, but when I call another form, from the first form, it loses its value. I've also tried creating a Static Function and declaring the variable as Static within the Function, but it still resets the variable when I move to a new form. How do i declare a variable, and where in my project do i place it so it can be available, maintain its value, and be modifiable between procedure calls and Form modules? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I just create a simple test with two forms.
I declared a public variable in a standard module, and set it to 17, then called form 1. On this I had a button which displayed the value then called form 2. This also had a button that displayed the value. It always showed 7 as expected. Any other oddities going on? -- HTH RP (remove nothere from the email address if mailing direct) "Chris W" wrote in message ... Hi, I thought i had a good understanding of Scope and lifetime of varaibles but i'm havibg a problem. I need to maintain and update the value of variable for the life of of the running app. I decalred it as public in a module and I set its value in a Form module. It maintains its value as long as the first form is running, but when I call another form, from the first form, it loses its value. I've also tried creating a Static Function and declaring the variable as Static within the Function, but it still resets the variable when I move to a new form. How do i declare a variable, and where in my project do i place it so it can be available, maintain its value, and be modifiable between procedure calls and Form modules? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
keeping a shape constant regardless of changes in variables | Excel Discussion (Misc queries) | |||
Keeping variables in a formula | Excel Discussion (Misc queries) | |||
How to keep a Variable alive after a Call to Sub Routine | Excel Discussion (Misc queries) | |||
Keeping track of Global variables | Excel Programming | |||
How to keep an Array 'alive' | Excel Programming |