Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm working on some code that asks the user via userform to select a
checkbox if they want a certain result. I've publicly declared a boolean variable bHdr to capture whether they've selected the box (true) or not (false). I checked to made sure the result of that selection was passed from the userform code back to the original macro by putting a watch on the variable in the userform code. When control passed back to the original macro, the value of bHdr became "empty". Then I put a separate watch on the variable bHdr in the original code. It shows the variable having a value "true" if I checked the checkbox. I'm confused about this. If the variable is declared publicly, why is it empty in the context of the userform once it is closed, but true in the context of the module? What does this mean? Exactly how does VBA handle this kind of variable? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Public variables defined in code modules behind userforms are properties of the form, so I guess they are destroyed when the form is. On the other hand, if your public variable IN THE CODE MODULE FOR THE USERFORM is called TestBoolea.n thenwhen you call the userform you can do: Userform1.Show myBoolean = Userform1.TestBoolean Unload Userform1 regards Paul On Mar 20, 2:50 pm, "davegb" wrote: I'm working on some code that asks the user via userform to select a checkbox if they want a certain result. I've publicly declared a boolean variable bHdr to capture whether they've selected the box (true) or not (false). I checked to made sure the result of that selection was passed from the userform code back to the original macro by putting a watch on the variable in the userform code. When control passed back to the original macro, the value of bHdr became "empty". Then I put a separate watch on the variable bHdr in the original code. It shows the variable having a value "true" if I checked the checkbox. I'm confused about this. If the variable is declared publicly, why is it empty in the context of the userform once it is closed, but true in the context of the module? What does this mean? Exactly how does VBA handle this kind of variable? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Variable type Confusion | Excel Programming | |||
ISNumber - What Context? | Excel Worksheet Functions | |||
Context menu | Excel Programming | |||
context for the command bar | Excel Programming | |||
Context sensitive help | Excel Programming |