Results 1 to 12 of 12

Thread: Deleting a Picture box - contents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    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
    VB Code:
    1. Picture1.cls

    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.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    Re: How can i....?

    Quote 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?

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    Re: Deleting a Picture box - contents

    ok . sorry

  6. #6
    Member
    Join Date
    Jan 2007
    Posts
    36

    Re: Deleting a Picture box - contents

    Try this code...

    For i = 0 To 9
    Unload Combos(i)
    Next i

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    Re: Deleting a Picture box - contents

    Run time error.

    "Can't load or unload this object"

    sorry it doesnt work.thx for the try

  8. #8
    Member
    Join Date
    Jan 2007
    Posts
    36

    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    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

  10. #10
    Member
    Join Date
    Jan 2007
    Posts
    36

    Re: Deleting a Picture box - contents

    This is the code i've used...
    VB Code:
    1. Dim combos(10) As ComboBox
    2.  
    3. Private Sub DeleteCombo_Click()
    4.     For i = 0 To 10
    5.     combos(i).Visible = False
    6.     Next i
    7.  
    8. End Sub
    9.  
    10. Private Sub LoadCombo_Click()
    11.     For p = 0 To 10
    12.     Set combos(p) = Me.Controls.Add("VB.Combobox", "cmdButton" & Me.Controls.Count, Picture1)
    13.    
    14.     With combos(p)
    15.     .Left = x + 125
    16.     .Top = y
    17.     .Width = 110
    18.     .AddItem "1"
    19.     .Visible = True
    20.     End With
    21.     x = x + 900
    22.     Next p
    23. End Sub

    LoadCombo button loads all the comboboxes and DeleteCombo deletes all the comboboxes

  11. #11
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Deleting a Picture box - contents

    Here ya go. I thought you would have had a look at the other demo first however.
    Attached Files Attached Files

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    100

    Re: Deleting a Picture box - contents

    thnx . ill give it a try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width