473,322 Members | 1,846 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,322 software developers and data experts.

Compare items in two list boxes

Hi,

I am new to VB programming and got stuck up at a place where I want to compare two items in two list boxes. The idea is to avoid recurrence of the same item in the second list box (items are selected from first list box by double clicking and store in second one ) even if it selected repeatedly in first list box.

Please help me

Raj
Jan 21 '08 #1
2 5037
daniel aristidou
491 256MB
Hi,

I want to compare two items in two list boxes. The idea is to avoid recurrence of the same item in the second list box (items are selected from first list box by double clicking and store in second one ) even if it selected repeatedly in first list box.
this is a long method of doing it...out of the top of my head.
Note i did this with combo boxes alter it for your needs

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim isinsecond As VbTriState
  3.  
  4. Private Sub Combo1_Click()
  5. Dim secoondndcomboxcount As Integer
  6. secoondndcomboxcount = Combo2.ListCount
  7. isinsecond = False
  8. Dim i As Integer
  9. If secoondndcomboxcount = 0 Then
  10.   Combo2.AddItem (Combo1.Text)
  11. End If
  12. For i = 0 To secoondndcomboxcount - 1
  13.   If Combo1.Text = Combo2.List(i) Then
  14.     isinsecond = vbTrue
  15.     secoondndcomboxcount = secoondndcomboxcount - 1
  16.   End If
  17. Next i
  18. If isinsecond = vbFalse Then
  19.   Combo2.AddItem (Combo1.Text)
  20. End If
  21. End Sub
Jan 21 '08 #2
Hi,
Thanks a lot.I hope I can do something with the code given.

Warm regards

Raj
Jan 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Niels | last post by:
Hello, I'm trying to get te index of a specific text in a ComboBox. The ComboBox is filled by searching for filenames in a directory. The text of the last item selected in the ComboBox is saved in...
3
by: james.dixon | last post by:
Hi I was wondering if anyone else had had this problem before (can't find anything on the web about it). I have three select elements (list boxes - from here on I'll refer to them as 'the...
4
by: Colleyville Alan | last post by:
I am trying to use a list box to allow users to select items, the results are queried based on the selection and written to a spreadsheet. If the item already exists on their current spreadsheet,...
3
by: pagates | last post by:
Hello Gurus, I have a listview, and I only want to add unique items. The problem is, my code is blowing by my "Contains" statement, adding the item, and then hitting my Compare code in the...
3
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays blank, and through javascript it is possible to move items from one box to another, this works fine, I followed an article titled...
5
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items from one box to another and vice a...
4
by: Justin Emlay | last post by:
I have two lists. These can be in either table form or array. That is, my data is in a dataset which I can move to an array if need be. ListA is a master list and it contains all items. ListB...
3
by: e | last post by:
I have a form which includes a list box populated with items from a query. When a user double clicks on a row in the list box, each column item is put into a specific text box. The problem...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.