JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Sorting a List Box

You're very proud of your new program's list box, which lists all the classical music recordings available for the last 40 years. But the Testing Department isn't so happy. They ask: Can't you alphabetize that list?

You can alphabetize the items in a list box by setting its Sorted property to True (it's False by default) at design time or run time. That's all it takes, just set its Sorted property to True. (In fact, I've known lazy programmers who sorted arrays of text by placing the text into a hidden list box and then reading it back to save writing the code for the string comparisons.)


You should know, however, that sorting a list box can change the indices of the items in that list box (unless they were already in alphabetical order). After the sorting is finished, the first item in the newly sorted list has index 0, the next index 1, and so on.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor