Thread: Question Only
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Question Only

Make sure you are declaring your variables outside of any procedures
I've tested the following code. First run test1. It sets the variable test
as one then displays it in a message box. Then run test 2. It still
displays 1 in the message box because test is still holding its value.

I usually create a mode called "Declarations" for all my public variables
and do not write any other code there.

Public test As Integer

Sub test1()
test = 1
MsgBox test
End Sub

Sub test2()
MsgBox test
End Sub
--
JNW


"Noemi" wrote:

When you have public modules and have declared variables why is it when we
have End in the code (due to information is missing and needs to be added),
why do the variables lose their data

ie
If I have dbcountry = 1 when the program comes to the word End, the
dbcountry = 0.

I dont understand why this happens as I have Public dbcountry as double in a
standard module so I can use over multiple modules.

Any answers would be very much appreciated.
thanks
Noemi