SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 3rd, 2004, 03:52 AM
Flona_25 Flona_25 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 8 Flona_25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Combo Boxes...Please Advice

if i have a combo box and it contains a records such as:
1 2 3 2 4 1 3 3
and i want to remove the records that are duplicated..since i am getting the records from Database
i only want tha number to appear once..
How can i do this?
i used this code but it doesn't work right. it keeps giving some similar records and
sometimes elminates some records.
May i have some help in this..thanx a lot in advance

The Code is as follows:

For i = 0 To cmbRecords.ListCount - 1
num = cmbRecords.List(i)
For k = 1 To cmbRecords.ListCount - 1
If num = cmbRecords.List(k) Then
cmbRecords.RemoveItem (k)
End If
Next k
Next i

where the cmbRecords is the combo box .
Please help as soon as possible..Thanx again

Reply With Quote
  #2  
Old August 3rd, 2004, 08:21 AM
QueenVBA QueenVBA is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 22 QueenVBA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 43 sec
Reputation Power: 0
How are you loading the combobox for the database?

Reply With Quote
  #3  
Old August 10th, 2004, 10:47 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Hi,

I can explain why your code sometimes eliminates duplicate records and on other times eliminates normal records. When you remove an item, the whole list underneath that item moves up by 1. A common mistake when it comes to comboboxes.

If you populate the combobox from a database, it is best to do a SELECT DISTINCT or SELECT DISTINCT ROW. The former and the later do the same, but not all SQL dialects understand both of them. Look in the reference for your SQL syntax to see which one you must use (or try them both and see what gives an error).

If you got any questions, feel free to ask.

Grtz.©

M.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Combo Boxes...Please Advice


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway