By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Compare items in two list boxes

P: 12
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
Share this Question
Share on Google+
2 Replies


daniel aristidou
100+
P: 491
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

P: 12
Hi,
Thanks a lot.I hope I can do something with the code given.

Warm regards

Raj
Jan 22 '08 #3

Post your reply

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