Results 1 to 4 of 4

Thread: If 2 item exist in a combobox I wanna add one more?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2002
    Posts
    665

    Question If 2 item exist in a combobox I wanna add one more?

    How can I search in a combobox if 2 different item exists? And if they exsist I wanna add one more item.

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: If 2 item exist in a combobox I wanna add one more?

    Hope this helps.. its off the head so i havent tried it.. but should work..

    Code:
    dim x as integer
    
    for x = 0 to listbox1.listcount -1
    listbox1.listindex = x
       if listbox1.text = "File1" or listbox1.text = "File2" then
       listbox1.add "Add new Item"
       end if
    next x
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  3. #3
    Addicted Member
    Join Date
    Jun 2006
    Posts
    172

    Re: If 2 item exist in a combobox I wanna add one more?

    Code:
    item1found = False
    item2found = False
    
    item1 = "1"
    item2 = "2"
    
    
    
    For i = 0 To Combo1.ListCount - 1
       If Combo1.List(i) = item1 Then
           item1found = True
           Exit For
       End If
    Next i
    
    For i = 0 To Combo1.ListCount - 1
       If Combo1.List(i) = item2 Then
           item2found = True
           Exit For
       End If
    Next i   
    
    If item1found = True and item2found = True Then
        'Add whatever
    Else
        'both items were not found
    End If
    Kind of ugly, what it works.
    • If you found my post to be helpful, please rate me.

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: If 2 item exist in a combobox I wanna add one more?

    do a search for LB_FINDSTRINGEXACT, you'll find faster API ways of doing it

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