Q: List Box to List Box Code 
Author Message
 Q: List Box to List Box Code

I'd like to find some code which will do the following:

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.

Any help would be greatly appreciated.  Thanks a lot!



Mon, 02 Feb 1998 03:00:00 GMT  
 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) -



Mon, 02 Feb 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to list macro names in a combo box or a list box

2. Help wanted with file list boxes and list boxes

3. VB List Box Versus Access List Box

4. List box within List box

5. List box within List box

6. List box within List box

7. dialog box with list box or combo box

8. Limiting Access to Text Boxes, List Boxes and Combo Boxes

9. Listing all tables or queries in a list/combo box

10. How to list macro names in a combo box or a list

11. How to list macro names in a combo box or a list

12. Rebuild select list for combo/list box

 

 
Powered by phpBB® Forum Software