Post by Jarrod Lange on Nov 23, 2005 14:02:39 GMT -5
Hi There
Have been playing around with the VBCorlib and think it is fantastic. Especially the collection objects - ArrayList, HashTable and SortedList.
However, with version 1.5.0.4 I am having problems with the SortedList. It doesn't seem to remove items from the list correctly.
If I remove the first item, the 1st and 2nd items disappear and I am left with a blank item and the end of the list. If I proceed to remove more rows, VB eventually spits the dummy and throws a invalid operation error.
Here is some code that I can get to crash every time:
Option Explicit
Private Sub Command1_Click()
Dim oSortedList As VBCorLib.SortedList
Dim v As Variant
Dim sValues As String
Set oSortedList = VBCorLib.NewSortedList(, , 0)
With oSortedList
.Add "a", "a"
.Add "z", "z"
.Add "b", "b"
.Add "c", "c"
.Add "y", "y"
.Add "x", "x"
.Add "m", "m"
.Add "l", "l"
.Add "q", "q"
End With
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'a'"
MsgBox "Removing 'a'"
oSortedList.Remove "a"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'q'"
MsgBox "Removing 'q'"
oSortedList.Remove "q"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'y'"
Debug.Print "Removing 'y'"
oSortedList.Remove "y"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
Debug.Print sValues
oSortedList.Clear
Set oSortedList = Nothing
End Sub
I have tried this code through the VB IDE with a compiled VBCorlib DLL, a compiled EXE and even through the IDE with the VBCorLib source code open.
Any ideas ??
Cheers
J
Have been playing around with the VBCorlib and think it is fantastic. Especially the collection objects - ArrayList, HashTable and SortedList.
However, with version 1.5.0.4 I am having problems with the SortedList. It doesn't seem to remove items from the list correctly.
If I remove the first item, the 1st and 2nd items disappear and I am left with a blank item and the end of the list. If I proceed to remove more rows, VB eventually spits the dummy and throws a invalid operation error.
Here is some code that I can get to crash every time:
Option Explicit
Private Sub Command1_Click()
Dim oSortedList As VBCorLib.SortedList
Dim v As Variant
Dim sValues As String
Set oSortedList = VBCorLib.NewSortedList(, , 0)
With oSortedList
.Add "a", "a"
.Add "z", "z"
.Add "b", "b"
.Add "c", "c"
.Add "y", "y"
.Add "x", "x"
.Add "m", "m"
.Add "l", "l"
.Add "q", "q"
End With
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'a'"
MsgBox "Removing 'a'"
oSortedList.Remove "a"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'q'"
MsgBox "Removing 'q'"
oSortedList.Remove "q"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
MsgBox sValues
sValues = vbNullString
Debug.Print "Removing 'y'"
Debug.Print "Removing 'y'"
oSortedList.Remove "y"
For Each v In oSortedList.Values
Debug.Print "Item: " & CStr(v)
sValues = sValues & "Item: " & CStr(v) & vbCrLf
Next v
Debug.Print sValues
oSortedList.Clear
Set oSortedList = Nothing
End Sub
I have tried this code through the VB IDE with a compiled VBCorlib DLL, a compiled EXE and even through the IDE with the VBCorLib source code open.
Any ideas ??
Cheers
J