Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
keeping a shape constant regardless of changes in variables Osvy Excel Discussion (Misc queries) 0 March 28th 06 04:49 AM
Keeping variables in a formula Brian Mann Excel Discussion (Misc queries) 1 September 22nd 05 09:13 PM
How to keep a Variable alive after a Call to Sub Routine Dennis Excel Discussion (Misc queries) 2 July 27th 05 10:57 PM
Keeping track of Global variables Stuart[_5_] Excel Programming 3 July 15th 04 02:14 PM
How to keep an Array 'alive' Fred[_17_] Excel Programming 6 July 1st 04 07:41 AM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"