![]() |
Keeping a Variables value alive.
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. |
Keeping a Variables value alive.
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. |
All times are GMT +1. The time now is 11:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com