Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Variable Changes

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
I have dimensioned the variable "Area" as public. After calculating the area, I need to leave the general module where Area is listed and then come back from time to time to perform other routines using the value previously calculated. For some reason, it will not stay constant and will always revert to the original value before the calculations were done. I was under the impression that a public variable would always remain at its last value.

ie; One of the calculations is "Area = Area + 8". I get the correct response. If the area was origenally 3, then the new value of Area is 11. However, when I return to the module after leaving, the value has returned to 3!

I hope this makes some sense.
Bill
 
Use "Static" instead of "Dim" when declaring the variable.
 
All you have to do is declare the variable as public in a module. Once you assign a value to it, it will remain until the variable is changed, or the database is closed.

Public MyVar as String

I know it works, I have used this for user ID's, or other ID's many times. Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top