VB6 Listbox

I'm posting an exercise of Visual Basic Properties for the List Box tool. Check this out.

Given this two listboxes where the first listbox lists the different states of the United States, and the second listbox with an empty list.

Image by VBExplorer

Let's rename the lists of the first listbox. Instead of a list of the different states, try to list down different dishes and put a little label below the listbox with the caption, Menu. Name the first listbox as lstMenu. Under the second listbox with an empty list, put another label below it with the caption of Orders. Name the second list box as lstOrders.

So what's the catch? Once you select a dish from lstMenu and press the >>>> button, that dish will be copied to lstOrders.

Solution:

Double click on the >>>> button and type the following:

Private Sub cmdLeft_Click()
listOrders.RemoveItem listOrders.ListIndex
End Sub

Next, double click on the second button (with the caption of <<<<) and type the code:

Private Sub cmdRight_Click()
listOrders.AddItem (listMenu)
End Sub

Once you get it right, you are now free to play with menu-order system by clicking on the >>>> and <<<< buttons. See how the texts appear and disappear in the empty listbox.

2 comments:

Extended Search

Custom Search
Hello World