|
-
Mar 8th, 2007, 05:12 AM
#1
Thread Starter
Lively Member
check repeated item in list box
i want to check the item in list box whether has repeated or not......
how to do it?
-
Mar 8th, 2007, 06:44 AM
#2
Junior Member
Re: check repeated item in list box
To check the uniqueness of an Item in a list box I think you need to add an identifier in the ItemData property fpr each Item. You can then access this value to check for duplicates.
Below is an example:
Code:
listbox1.AddItem "No 1"
listbox1.ItemData(listbox1.NewIndex) = 1
listbox1.AddItem "No 2"
listbox1.ItemData(listbox1.NewIndex) = 2
Dim i As Long
For i = 0 To listbox1.ListCount - 1
If listbox1.ItemData(i) = 5 Then
MsgBox "No 5 exists"
Else
listbox1.AddItem "No 5"
listbox1.ItemData(listbox1.NewIndex) = 5
End If
Next
Hope this helps
-
Mar 8th, 2007, 07:16 AM
#3
Re: check repeated item in list box
 Originally Posted by chxxangie
i want to check the item in list box whether has repeated or not......
how to do it?
Do you mean if there are duplicate entries of the same item?
-
Mar 9th, 2007, 12:34 AM
#4
Thread Starter
Lively Member
Re: check repeated item in list box
 Originally Posted by Hack
Do you mean if there are duplicate entries of the same item?
yup....
-
Mar 9th, 2007, 03:54 AM
#5
Re: check repeated item in list box
how are you loading items into the list...if you are checking with a text box then use like this
Code:
For i = 0 To List1.ListCount - 1
If Text1.Text = List1.List(i) Then
MsgBox "Duplicate: " & List1.List(i)
End If
Next
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Mar 9th, 2007, 04:29 AM
#6
Re: check repeated item in list box
do a search for LB_FINDSTRINGEXACT
-
Mar 9th, 2007, 09:26 AM
#7
Re: check repeated item in list box
Track the index each time an item in the list box is clicked on. Use a simple integer vector array that changes to True when it occurs.
Optionally, you could also increment the array element to count the number of times the item has been clicked on in the list box. That gives you more information.
Last edited by Code Doc; Mar 9th, 2007 at 10:00 AM.
Doctor Ed
-
Mar 9th, 2007, 09:49 AM
#8
Re: check repeated item in list box
I have some questions.
Do you want to prevent duplicates? If so, take a look at ganeshmoorthy's post?
Do you want to allow duplicates, but flag them? If so, there is code for that as well.
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
|