No dups in a ComboBox?

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I've been checking the doc for the combobox to see it there is some way I
can set it up to be sorted (I found that) and to have no duplicate entries.

I don't see any way to avoid dups unless Sorted implies that.

Is there a simple way to avoid dups or should I program to accomplish that?


Thanks
 
I've been checking the doc for the combobox to see it there is some way I
can set it up to be sorted (I found that) and to have no duplicate entries.

I don't see any way to avoid dups unless Sorted implies that.

Is there a simple way to avoid dups or should I program to accomplish that?


Thanks

You can use the contains method to discover if an object already exists
before you add it...

If Not myCombo.Items.Contains(theValue) Then
myCombo.Items.Add (theValue)
End If

You can also use the FindString and FindStringExact methods to see if
certain text is contained...

If myCombo.FindStringExact("Dog") = -1 Then
myCombo.Items.Add ("Dog")
End If

HTH
 
Perfect

Thanks

Tom Shelton said:
You can use the contains method to discover if an object already exists
before you add it...

If Not myCombo.Items.Contains(theValue) Then
myCombo.Items.Add (theValue)
End If

You can also use the FindString and FindStringExact methods to see if
certain text is contained...

If myCombo.FindStringExact("Dog") = -1 Then
myCombo.Items.Add ("Dog")
End If

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top