Korea lst plastic
1 and SelCount are selected numbers, and Selected(X)=True is whether an item is selected.

And LstLeft. SelCount & gt0 means that if the selected number is greater than 0, LstLeft will start the loop.

Whether to use SelCount or Selected(X) should be decided according to actual needs.

2. Two loops are nested to ensure that each selected item in LstLeft is moved to LstRight, and the function of Exit For is to check it again from the beginning every time an item is deleted.

Every time an item is deleted in LstLeft, the serial numbers of the following items are-1. If the cycle continues, the expected effect may not be achieved. In fact, this nesting is not only inefficient, but also difficult to read.

3. Next is a keyword of the For loop, which cannot be less. Next is followed by the variable name of the For loop, such as Next X here, and the variable name is X. Next can also be written directly without the variable name.

4. If you change next to the End if, you will exit the For loop and continue the While loop every time you check the first item. The While loop will traverse the For loop again and exit the For loop after checking the first item. ...

If you don't just choose the first item, you will form an infinite loop, which is manifested by the program stopping responding.

-

Do you think this efficiency is higher than before? It only needs to be checked twice from beginning to end.

Private Sub CmdRight_Click ()

Mark x as an integer.

If left. SelCount & gt So 0

For X = 0 to LstLeft. LstCount - 1

If left. Selected(X) = True Then

LstRight。 AddItem LstLeft。 List (x)

If ... it will be over.

Next x

For X = 0 to LstLeft. LstCount - 1

If left. Selected(X) = True Then

Turn left. Remove item x

If ... it will be over.

Next x

End joint