Computing.Net > Forums > Programming > VB listboxes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB listboxes

Reply to Message Icon

Name: black912star
Date: March 3, 2005 at 16:16:32 Pacific
OS: Windows 2000
CPU/Ram: N/A
Comment:

Hi guys,

I'm new to VB/VBA and my question is very simple (I hope). I have 2 listboxes in my Access form. Can anyone help me with a code for a button that moves items from the first listbox to the second one. My first list box gets it's data from a table.

Thanks,



Sponsored Link
Ads by Google

Response Number 1
Name: egkenny
Date: March 3, 2005 at 17:30:45 Pacific
Reply:

It is easy to do this with normal listboxes:

ListBox 1 Name: left_list
ListBox 2 Name: right_list
Command Button Name: CopyList

To copy from the 1st box to the 2nd:

Private Sub CopyList_Click()
Dim item As String
For i = 0 To right_list.ListCount - 1
right_list.RemoveItem (0)
Next i
For i = 0 To left_list.ListCount - 1
item = left_list.ItemData(i)
right_list.AddItem (item)
Next i
End Sub

To do more requires more information about the source of the data from you.


0

Response Number 2
Name: StuartS
Date: March 3, 2005 at 18:20:30 Pacific
Reply:

While the above code will copy the entire contents of List1 to List2, the following code will just copy selected items by double clicking on the item to be copied.

Private Sub List1_DblClick()

List2.AddItem List1.list(List1.ListIndex)
List1.RemoveItem List1.ListIndex

End Sub

Stuart


0

Response Number 3
Name: Kamran
Date: March 5, 2005 at 12:32:08 Pacific
Reply:

How can i use command Button to open folder in DirListBox like a user does?


0

Response Number 4
Name: StuartS
Date: March 5, 2005 at 14:01:03 Pacific
Reply:

Link it to a FileListBox.

If you have a new question, start a new thread. Otherwise there is a good chance it will not get answered.

Stuart


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB listboxes

vb+listbox www.computing.net/answers/programming/vblistbox/2060.html

Scrolling Through VB Listbox Items www.computing.net/answers/programming/scrolling-through-vb-listbox-items-/17236.html

Access 2003 & query parameters www.computing.net/answers/programming/access-2003-amp-query-parameters/12931.html