473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Eleminate duplicate items in a listbox

Hi
I am developing a VB.NET application,in that application i
have a listbox.When adding items to the listbox some
duplicate items are added,how can i prevent listbox items
from duplication.If any one knows please suggest me.

Mamatha
Nov 21 '05 #1
5 8891
'Test to see if it is already in list

If ListBox1.Items.Contains(TextBox1.Text) Then

MsgBox("This is already in the list")

Else

ListBox1.Items.Add(TextBox1.Text)

End If
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"mamatha" <ma***********@yahoo.com> wrote in message
news:40****************************@phx.gbl...
Hi
I am developing a VB.NET application,in that application i
have a listbox.When adding items to the listbox some
duplicate items are added,how can i prevent listbox items
from duplication.If any one knows please suggest me.

Mamatha

Nov 21 '05 #2
Are you loading from the DATABASE.
If 'Yes' then use DISTINCT in the SQL, bound it to listbox, you will only
have distinct item in the list box.

Regards
Partha
"mamatha" <ma***********@yahoo.com> wrote in message
news:40****************************@phx.gbl...
Hi
I am developing a VB.NET application,in that application i
have a listbox.When adding items to the listbox some
duplicate items are added,how can i prevent listbox items
from duplication.If any one knows please suggest me.

Mamatha

Nov 21 '05 #3
Partha,
Are you loading from the DATABASE.
If 'Yes' then use DISTINCT in the SQL, bound it to listbox, you will only
have distinct item in the list box.


It is how you read "adding", when this is only the first initial time using
the datasource instead of the "ADD" you are completly correct, when is meant
afterwards this is not true.

Just trying to make it clear, because basicly there is nothing wrong with
your statement, however can be in mine opinion interpretted in another way.

Cor
Nov 21 '05 #4
Unfortunatley the OP was not detlailed in his/her discription of the issue.
As no mention of SQL/ACCESS Etc was mentioned, I thought perhaps that they
were adding to the list manually.

I suppose we shall see if the OP replies.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
Partha,
Are you loading from the DATABASE.
If 'Yes' then use DISTINCT in the SQL, bound it to listbox, you will only have distinct item in the list box.
It is how you read "adding", when this is only the first initial time

using the datasource instead of the "ADD" you are completly correct, when is meant afterwards this is not true.

Just trying to make it clear, because basicly there is nothing wrong with
your statement, however can be in mine opinion interpretted in another way.
Cor

Nov 21 '05 #5
Terry,

I had the same thought as you before I readed the message from Partha, where
I than thought that becauseof the listbox.add (which can be used to fill and
to add) can as well be true.

:-)

Cor
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: darren | last post by:
How, using asp.net (vb.net), can I remove multiple selected items from a listbox. Everything I try does not seem to work. Thanks in advance.
1
by: pcb | last post by:
Hi All, I have a multi-select listbox, that can have duplicate items (i.e samples numbers that are analyzed in duplicate - the sample IDs are not the same, but these IDs are hidden from the...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
4
by: Shi Mu | last post by:
I used the following method to remove duplicate items in a list and got confused by the error. >>> a , , ] >>> noDups='] ] Traceback (most recent call last): File "<interactive input>", line...
3
by: Jim McGivney | last post by:
In VWD I have an aspx page with a DropDownList control. The DropDownList is populated from a column from a table in an Access database. If there are duplicate values in the column they are added...
4
by: ejack | last post by:
int total = static_cast<int>(vComp.size()) - 1; int tTotalUnits = 0; float tTotalCostJob = 0; int i = 0; int j = 0; int counter = 0; bool foundFlag; vector<string> vItems;...
0
by: Walter Thizo | last post by:
I have substring the duplicate different records from file and i want to load those records inside listbox or paradox table distinctly - This is records from file : Student No 2001...
7
by: cathy25 | last post by:
Hi, My requirement is to check for duplicate items in a list of 16 strings.They will be entered by users like this...Item1,Item2,Item3....Item16. I need to check for the repeated items if any exists...
4
by: rajesh kunwar | last post by:
how can retrive listbox1 to listbox2 without duplicate value
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.