simple array read to combobox problem
i have an array , it stored integers "1,1,1,1,2,2,3,3,3"
how can i write the program to use for loop to read the integer to the combobox without repeated integers?
after read these integers to combobox, the combobox will have "1,2,3" only.
thanks!! :)
Re: simple array read to combobox problem
within your reading loop you can use something like..
VB Code:
if combobox1.Items.IndexOf(NewStringValue) = -1 Then ComboBox1.Items.Add(NewStringValue)
The indexof method of any kind of item list looks for that item and returns -1 if it's not found.
Bill
Re: simple array read to combobox problem
Quote:
Originally Posted by conipto
within your reading loop you can use something like..
VB Code:
if combobox1.Items.IndexOf(NewStringValue) = -1 Then ComboBox1.Items.Add(NewStringValue)
The indexof method of any kind of item list looks for that item and returns -1 if it's not found.
Bill
thanks!! it work! :thumb:
Re: simple array read to combobox problem
You can also use:
VB Code:
If Not myComboBox.Items.Contains(myValue) Then
myComboBox.Items.Add(myValue)
End If