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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Array UNLOAD problem 1

Status
Not open for further replies.

pungy

Instructor
Joined
Aug 5, 2007
Messages
71
Location
US
Okay. You may want to look at my other post "Control Array Show problem".
Now that I have it LOADED, How do I UNLOAD THEM
Code:
Private Sub Command1_Click()
Load Frame1(1)
Frame1(1).Top = Frame1(0).Top + Frame1(0).Height + 50
Frame1(1).Visible = True
Load Option1(1)
Set Me.Option1(1).Container = Me.Frame1(1)
Option1(1).Left = Option1(0).Left
Option1(1).Top = Option1(0).Top
Option1(1).Visible = True
Load Option2(1)
Set Me.Option2(1).Container = Me.Frame1(1)
Option2(1).Left = Option2(0).Left
Option2(1).Top = Option2(0).Top
Option2(1).Visible = True
Load Option3(1)
Set Me.Option3(1).Container = Me.Frame1(1)
Option3(1).Left = Option3(0).Left
Option3(1).Top = Option3(0).Top
Option3(1).Visible = True
End Sub

HOW DO I UNLOAD THEM?????

The objective is to remove all occurrences of the frame except for Frame1(0).

I tried a couple things:
Code:
Do until Frame1(Frame1.Ubound) = 0
unload frame1(frame1.ubound)
loop
This code did not work. I got an "Type Mismatch" error.

I then tried this, thinking I need to remove the OPTION controls first:
Code:
 Set Me.option1(option1.UBound).Container = Me.frame1(frame1.UBound)
    Do Until option1(option1.UBound) = 0
        Unload option1(option1.UBound)
    Loop
I realize I need to do this for all 3 option controls in the FRAME. With the code above, it's going out of the routine on the DO statement. When I did a debug.print, Option1.Ubound = 1

Can you help me with this code?
 
Do Until Option1.UBound = 0
Unload Option1(Option1.UBound)
Loop
 
HughLerwill:

Thanks for your valuable post. I modified my code a little and then added yours. It worked great.

Here is the modified code:
Code:
Private Sub Command1_Click()
Dim count As Single
count = 1
Do Until count = 5
    Load Frame1(count)
    Frame1(count).Top = Frame1(count - 1).Top + Frame1(count - 1).Height + 50
    Frame1(count).Visible = True
    Load Option1(count)
    Set Me.Option1(count).Container = Me.Frame1(count)
    Option1(count).Left = Option1(count - 1).Left
    Option1(count).Top = Option1(count - 1).Top
    Option1(count).Visible = True
    Load Option2(count)
    Set Me.Option2(count).Container = Me.Frame1(count)
    Option2(count).Left = Option2(count - 1).Left
    Option2(count).Top = Option2(count - 1).Top
    Option2(count).Visible = True
    Load Option3(count)
    Set Me.Option3(count).Container = Me.Frame1(count)
    Option3(count).Left = Option3(count - 1).Left
    Option3(count).Top = Option3(count - 1).Top
    Option3(count).Visible = True
    count = count + 1
Loop
End Sub

Private Sub Command2_Click()
Do Until Option1.UBound = 0
    Unload Option1(Option1.UBound)
    Unload Option2(Option2.UBound)
    Unload Option3(Option3.UBound)
Loop
Do Until Frame1.UBound = 0
    Unload Frame1(Frame1.UBound)
Loop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top