Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a strange problem with Excel 97 (I think this problem is
existing in the later versions also). Here is a simplified version of what I did. I created three command buttons in sheet1 and a userform in the project. When I display a form and then come back to the xlsheet, the values I assigned before for all variables are lost. I wrote the following code: Standard module: Public x as integer Sheet1: Private Sub CommandButton1_Click() Load UserForm1 End Sub Private Sub CommandButton2_Click() x = 4 UserForm1.show End Sub Private Sub CommandButton3_Click() MsgBox x End Sub Userform1: Private Sub Userform_Click() UserForm1.hide End Sub This is what I do when I run the program: I click buttons 1 and 2. Userform1 is displayed. When I click the form, it disappears. Then I click button 3. Now the messagebox displays the value 0 for x. What happened to the value I assigned to x in the click procedure of button 2? If I remove the 'Userform1.show' command from the the click procedure of button2, and repeat the above steps, I get the value 4 for x displayed in the messagebox. Can anyone explain? Strange isn't it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Name Assigned Formula Not Working | Excel Discussion (Misc queries) | |||
Hyperlink varaible substitution - How To | Excel Worksheet Functions | |||
Disappearance of Sheet Numbers | New Users to Excel | |||
Passing a named varaible to Excel's Autofilter | Excel Programming | |||
combo box selection disappearance | Excel Programming |