|
-
Jan 30th, 2007, 05:29 AM
#1
Thread Starter
Lively Member
Deleting a Picture box - contents
delete complete the contents in picture box?
Hello guys i am creating dynamicaly combo boxes in picture box. to erase them all i am using
but only the last combo erases and the other are still there......how can i erase them all?
Last edited by panais; Jan 31st, 2007 at 05:04 AM.
-
Jan 30th, 2007, 07:44 AM
#2
Re: How can i....?
Your better off using a control array of combo boxes, so you will just load/unload control array elements with index > 0...
-
Jan 31st, 2007, 04:49 AM
#3
Thread Starter
Lively Member
Re: How can i....?
 Originally Posted by leinad31
Your better off using a control array of combo boxes, so you will just load/unload control array elements with index > 0...
i am creating the combooxes with :
Set Combos(p) = Me.Controls.Add("VB.Combobox", "cmdButton" & Me.Controls.Count, Picture1)
With Combos(p)
.Left = x + 125
.Top = y
.Width = 110
.AddItem "1"
.Visible = True
End With
Next p
amd i have a delete button with :
Picture1.Cls
For i = 0 To 9
With Combos(i)
.Visible = False
End With
next i
but it doesnt work....what ma i doing wrong?
-
Jan 31st, 2007, 05:01 AM
#4
Re: How can i....?
Please please please, give your post a decent title, we need to know what it is!!
This thread (found by searching) has a demo in it about control arrays for a text box. It may give you enough to go on.
http://www.vbforums.com/showthread.p...=control+array
-
Jan 31st, 2007, 05:05 AM
#5
Thread Starter
Lively Member
Re: Deleting a Picture box - contents
-
Jan 31st, 2007, 05:16 AM
#6
Member
Re: Deleting a Picture box - contents
Try this code...
For i = 0 To 9
Unload Combos(i)
Next i
-
Jan 31st, 2007, 05:24 AM
#7
Thread Starter
Lively Member
Re: Deleting a Picture box - contents
Run time error.
"Can't load or unload this object"
sorry it doesnt work.thx for the try
-
Jan 31st, 2007, 05:38 AM
#8
Member
Re: Deleting a Picture box - contents
I don't know why Visible = False is not working for u...
The following code is working fine in my PC...
For i = 0 To 10
combos(i).Visible = False
Next i
I've used this code to load all the combo...
For p = 0 To 10
Set combos(p) = Me.Controls.Add("VB.Combobox", "cmdButton" & Me.Controls.Count, Picture1)
With combos(p)
.Left = x + 125
.Top = y
.Width = 110
.AddItem "1"
.Visible = True
End With
x = x + 300
Next p
-
Jan 31st, 2007, 05:48 AM
#9
Thread Starter
Lively Member
Re: Deleting a Picture box - contents
do u use a different button for deleting?
Is it in a differebt function or in the same?
mine is in different and it still dont work
-
Jan 31st, 2007, 05:55 AM
#10
Member
Re: Deleting a Picture box - contents
This is the code i've used...
VB Code:
Dim combos(10) As ComboBox
Private Sub DeleteCombo_Click()
For i = 0 To 10
combos(i).Visible = False
Next i
End Sub
Private Sub LoadCombo_Click()
For p = 0 To 10
Set combos(p) = Me.Controls.Add("VB.Combobox", "cmdButton" & Me.Controls.Count, Picture1)
With combos(p)
.Left = x + 125
.Top = y
.Width = 110
.AddItem "1"
.Visible = True
End With
x = x + 900
Next p
End Sub
LoadCombo button loads all the comboboxes and DeleteCombo deletes all the comboboxes
-
Jan 31st, 2007, 07:11 AM
#11
Re: Deleting a Picture box - contents
Here ya go. I thought you would have had a look at the other demo first however.
-
Jan 31st, 2007, 07:35 AM
#12
Thread Starter
Lively Member
Re: Deleting a Picture box - contents
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|