"" May Incorrectly Sort in VB List/Combo Box If Sorted=True

ID Number: Q74132

1.00

WINDOWS

Summary:

An example below demonstrates a problem using the Sorted property to

sort a string beginning with a bracket "[" in either a list box or

combo box in Microsoft Visual Basic programming system version 1.0 for

Windows.

This sorting problem is actually caused by Microsoft Windows 3.0

(buglist3.00) and is not caused by Visual Basic. Microsoft is

researching this problem and will post new information here as it

becomes available.

More Information:

The following steps duplicate the problem:

1. In the Visual Basic environment, choose New Project from the File

menu.

2. Place two list boxes or two combo boxes on the form.

3. From the Properties Bar, set the Sorted property for either the two

list boxes or two combo boxes to True.

Note: Do not invoke List1.Sorted = -1 within the code of an event

procedure because this causes the run-time error "'Sorted'

property cannot be set at run time."

4. Now add some code to the Form_Click event procedure. Below are two

separate examples of the code to add depending on if you are using

list boxes or combo boxes:

Sub Form_Click () Sub Form_Click ()

List1.AddItem "[" Combo1.AddItem "["

List1.AddItem "\" Combo1.AddItem "\"

List1.AddItem "a" Combo1.AddItem "a"

List2.AddItem "a" Combo2.AddItem "a"

List2.AddItem "\" Combo2.AddItem "\"

List2.AddItem "[" Combo2.AddItem "["

End Sub End Sub

5. Run the code by pressing the F5 function key or choosing Start from

the Run menu.

6. Click on the form to see the sequence "a [ \" in the first list box

or combo box and to see the different sequence "[ \ a" in the

second list box or combo box.

This reveals an inconsistency with an internal Windows 3.0 sorting

routine. If you replace the character "[" with the character "b", the

two boxes correctly sort in the same order: "\ a b". The problem is

with sorting the "[" character.

Additional reference words: 1.00 3.00