LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Muliple Userforms and multiple Stacks

From code initiated in my main form1, I want to hide form1 and show form2.
When done with form2, then re-show form1.

No matter which way I try and do this, my code runs up in multiple stacks
which don't terminate until final exit. In the example below, if I switch
forms several tmes by pressing CommandButtons 1 & 2 on main form1, only when
I finally exit are all the procedures completed.

This contrived example this does not pose a problem. But with a lot of
complex code involved I get a memory leak in some circumstances - in
particular, when I switch forms from a popup commandbar that was created
while on the main form.

This memory leak persists after I exit my app. However it is a one off, ie
having switched forms once in any given session of Excel, no further leak
occurs.

Switching forms from an OnTime macro does not appear to help.

Clearly there I'm doing something wrong and would appreciate pointers.

TIA,
Peter T

'//Userform1 with 3 CommandButtons

Private Sub CommandButton1_Click()
Debug.Print "UF1 UserForm2 start"
Me.Hide
UserForm2.Show

Me.Show
Debug.Print "UF1 UserForm2 end"
End Sub

Private Sub CommandButton2_Click()
Debug.Print "UF1 run Proc1 start"
Proc1
Debug.Print "UF1 run Proc1 done"
End Sub

Private Sub CommandButton3_Click()
Debug.Print "Unload UF1"
Unload Me
End Sub

'// end Userform1


'//Userform2 with 1 CommandButton

Private Sub CommandButton1_Click()
Debug.Print "unload UF2 "
Unload Me
End Sub
'// end Userform2



'// in a normal module
Sub test()
UserForm1.Show
End Sub

Sub Proc1()
Debug.Print "Proc 1 start"
Proc2
Debug.Print "Proc 1 done"
End Sub

Sub Proc2()
Debug.Print "Proc 2 start"
Proc3
Debug.Print "Proc 2 done"
End Sub

Sub Proc3()
Debug.Print "Proc 3 start"
UserForm1.Hide
UserForm2.Show
'comes back here when UF2 unloads
UserForm1.Show
Debug.Print "Proc 3 done"
End Sub
'// end normal module


 
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
column chart stacks data when i add a secondary vertical axis scott Charts and Charting in Excel 9 October 1st 08 09:50 PM
Obtaining Multiple Results using muliple Criteria from an Array Archie999 Excel Worksheet Functions 2 March 5th 07 02:52 PM
Multiple Userforms at once dok112[_32_] Excel Programming 0 October 7th 04 08:15 AM
Multiple Userforms open at once RockNRoll[_2_] Excel Programming 1 May 8th 04 11:10 PM
Multiple simultaneous macros and userforms Jex Excel Programming 3 April 27th 04 02:22 PM


All times are GMT +1. The time now is 08:54 PM.

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"