The information in this article applies to:
- Windows CE Toolkit for Visual Basic 5.0, version 1.0
SYMPTOMS
When a ListBox Sorted property is set to True, the items in the ListBox are
not sorted.
RESOLUTION
This bug requires a sort routine to be implemented manually if the ListBox
items need to be sorted. The following is a sample of how this might be
accomplished.
- Create a new Windows CE Project in Visual Basic 5.0. Form1 is created
by default.
- Place a ListBox (List1), a TextBox (Text1) and a CommandButton
(Command1) on Form1.
- Paste the following code into the General Declarations section of Form1:
Dim strArray()
Private Sub Form_Load()
'initialize the array
ReDim strArray(0)
AddItem strArray, "Utah"
AddItem strArray, "Washington"
AddItem strArray, "Virginia"
AddItem strArray, "Iowa"
AddItem strArray, "Oregon"
AddItem strArray, "Alabama"
AddItem strArray, "Mississippi"
AddItem strArray, "Ohio"
Sort strArray, List1
End Sub
Private Sub Command1_Click()
If Text1.Text <> "" Then
AddItem strArray, Text1.Text
Sort strArray, List1
End If
End Sub
Sub AddItem(inpArray(), inpItem)
ReDim Preserve inpArray(UBound(inpArray) + 1)
inpArray(UBound(inpArray)) = inpItem
End Sub
Sub Sort(inpArray(), inpList)
Dim intRet
Dim intCompare
Dim intLoopTimes
Dim strTemp
For intLoopTimes = 1 To UBound(inpArray)
For intCompare = LBound(inpArray) To UBound(inpArray) - 1
intRet = StrComp(inpArray(intCompare), _
inpArray(intCompare + 1), vbTextCompare)
If intRet = 1 Then 'String1 is greater than String2
strTemp = inpArray(intCompare)
inpArray(intCompare) = inpArray(intCompare + 1)
inpArray(intCompare + 1) = strTemp
End If
Next
Next
'clear the list and repopulate.
inpList.Clear
For intCompare = 1 To UBound(inpArray)
inpList.AddItem inpArray(intCompare)
Next
End Sub
- Press the F5 key to run the Project.
- Type some text into Text1.
- Click Command1 to add the item into the ListBox, and note that the new
item is in the proper sort order.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. We are researching this
bug and will post new information here in the Microsoft Knowledge
Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new Windows CE Project in Visual Basic 5.0. Form1 is created
by default.
- Place a ListBox (List1), a TextBox (Text1) and a CommandButton
(Command1) on Form1.
- Set the Sorted property of List1 to True.
- Paste the following code into the General Declarations section of Form1:
Option Explicit
Private Sub Command1_Click()
List1.AddItem Text1.Text
End Sub
Private Sub Form_Load()
Command1.Caption = "Add Text To List Box"
Text1.Text = ""
List1.Clear
End Sub
- Press the F5 key to run the project.
- Type "Washington" in Text1 and click Command1.
- Type "Alaska" in Text1 and click Command1.
- Type "Utah" in Text1 and click Command1.
- Note that they are not sorted.
Keywords : vb5all vbce
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending
|