borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (SIP code)Next Topic (How to disbale Checked lines in list View ?) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Redundant entries in a ComboBox Solved Topic
Poster Message
joyride_us
Level: Protégé

Registered: 27-07-2006
Posts: 5

Ads by Lake Quincy Media
icon Redundant entries in a ComboBox

Hi,
my program adds entries in a ComboBox. I woud like to avoid to insert the same entry (actually IPAddresses) twice by checking if this entry already exist in the COmbobox before  inserting it. How could Ido this with VB5 ?
Thank you

Ads by Lake Quincy Media
27-09-2006 at 01:37 PM
View Profile Send Email to User Show All Posts | Quote Reply
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 256
icon Re: Redundant entries in a ComboBox

may this help


Combo1.AddItem "test"
Combo1.AddItem "test1"
Combo1.AddItem "test2"


Dim i As Long, upperI As Long
Dim j As Long, upperJ As Long

upperI = Combo1.ListCount - 1

For i = 0 To upperI
    For j = upperJ To 0 Step -1
    If "test" = Combo1.List(i) Then
    MsgBox Combo1.List(i) & " already exist "
    End If
    Next j
Next i

29-09-2006 at 01:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
joyride_us
Level: Protégé

Registered: 27-07-2006
Posts: 5
icon Re: Redundant entries in a ComboBox

Him
thanks
I fixed it with (nbitem2 is the number of entries in the combo box) , works great :


'avoid duplicates in the combo list
testIP = 1
check = 0
Do While testIP <= nbitem2
    
    If Combo1.List(testIP) = hostIP Then
      check = 1
    End If
      testIP = testIP + 1
Loop
    
If check = 0 Then
Combo1.AddItem (hostIP)
nbitem2 = nbitem2 + 1
End If

Thank you anyway!

05-10-2006 at 07:18 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Redundant entries in a ComboBox Solved Topic
Previous Topic (SIP code)Next Topic (How to disbale Checked lines in list View ?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder