Results 1 to 7 of 7

Thread: Howto remove all items from a combobox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    How do I remove al items from a combobox but leave the comboboxes text intact...

    Also it should not create an error if there are no items in the list...

  2. #2
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    use .clear to remove all items from list.
    When you clear the list, add the text to a temp variable and set the text back after the list is cleard.

    code examplpe with one combo and one button:
    Code:
    Private Sub Command1_Click()
    Dim temp As String
    temp = Combo1.Text
    Combo1.Clear 'clear context of combo
    Combo1.Text = temp 'set text of combo
    End Sub
    
    Private Sub Form_Load()
    Dim intI As Integer
    
    For intI = 0 To 10  'fill combo with item
        Combo1.AddItem "string " & intI
    Next intI
    
    Combo1.Text = Combo1.List(0) 'set item1 as text
    End Sub
    Hope this is what you were asking for

    ------------------
    On Error Goto Bed :0)
    [email protected]


  3. #3
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    Post

    Hey OnError, can you tell me how to do that thing where the code is in smaller text with a border above and below? Sorry for being a thicky.

  4. #4
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    They have something here that they call ubb-tag's instead of html-tag's.
    This page is from FAQ:can I usa html-tag's in my message? http://www.vb-world.net/ubb/ubbcode.html


    And my on error goto bed :0)....
    is set in my profile and then I check the "Show signature: include ......................... checkbox below.

    And the smiling faces can you read about in FAQ:Smilies

    Oooop's maybe that was some info that you already knew about

    By the way, wasn't there someone here who didn't like our missuse of ... ... etc


    Good luck

    ------------------
    On Error Goto Bed :0)
    [email protected]



    [This message has been edited by onerrorgoto (edited 11-23-1999).]

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    I must say that I think those block quotes of code is totally useless, because when you copy and paste the code into VB all the code end up on one line.

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  6. #6
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    It only seems to be a problem with IE5 it works fine for IE3 & 4.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    I believe that if you click the "Edit" icon on someone's post, you will be able to copy what you need and have the formatting retained. You won't, of course, be able to actually edit the code.

    ------------------
    Marty

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