
Q: List Box to List Box Code
Quote:
>There will be two list boxes side by side and two arrows in between the
>two list boxes, one pointing towards each of the list boxes. When the
>user highlights one of the items in a list box and hits the arrow
>pointing to the other list box I'd like that item to move from one list
>box to another. I've seem similar functionality in many programs, so I'm
>assuming there's some code of this already available.
Here is how you can move items from one list box to another:
two lists, named List1 and List2
button named cmdAddItem
cmdAddItem_Click
dim i as integer
for i = 0 to List1.ListCount-1
if List1.Selected(i) = TRUE then
foo = List1.List(i)
List1.RemoveItem i
List2.List(List2.ListCount) = foo
exit for
end if
next i
end
This code moves an item from List 1 that is highlighted/selected to the
bottom of List2. Simply switch the List1 and List2 in the above code to
move things back to List1 from List2 with another button.
Good luck,
RLH
Sr. P/A
Smith Barney Inc. NYC
Equity Systems
--
"In what distant deeps or skies | Ryan L. Heil
On what wings dare he aspire? |
What the hand dare seize the fire?" | - William Blake 1793(1794) -