|
-
Feb 5th, 2006, 12:24 PM
#1
Thread Starter
New Member
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!!
Last edited by DarkDragoon; Feb 5th, 2006 at 01:17 PM.
-
Feb 5th, 2006, 12:33 PM
#2
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
-
Feb 5th, 2006, 01:16 PM
#3
Thread Starter
New Member
Re: simple array read to combobox problem
 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!
-
Feb 5th, 2006, 05:37 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|