473,788 Members | 2,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8930
'Test to see if it is already in list

If ListBox1.Items. Contains(TextBo x1.Text) Then

MsgBox("This is already in the list")

Else

ListBox1.Items. Add(TextBox1.Te xt)

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******** ******@TK2MSFTN GP09.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
19574
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
4240
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 user). I want to loop through the items on the listbox, but only use unique sample numbers. Here is what I have:
10
3304
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
3632
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 1, in ? TypeError: iterable argument required
3
1866
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 to the DropDownList. Is there a way to eliminate duplicate items on the DropDownList ? Thanks, Jim
4
2446
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; vector<string> vHolding;
0
1359
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 2001 2001
7
23046
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 and need to reset it to zero or null. Could any body point me in a direction to write the logic in C#? Thanks, Cathy
4
3155
by: rajesh kunwar | last post by:
how can retrive listbox1 to listbox2 without duplicate value
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.