The following code:
Dim w As New JSONArray
w.AddItem("a")
w.AddItem("b")
w.AddItem("c")
Call w.ReplaceItemValue(1, "new")
MsgBox w.ToJSON()
The expected result is:
[“a”,“new”,“c”]
Actual results are:
[“a”,“b”,“c”]
Problem lies in the the following code:
Public Sub ReplaceItemValue(p_iIndex As Integer, p_vValue As Variant)
On Error Goto ErrorHandler
If Isarray(Me.m_vData) Then
If Ubound(Me.m_vData) <= p_iIndex Then
If Isobject(p_vValue) Then
Set Me.m_vData(p_iIndex) = p_vValue
Else
Me.m_vData(p_iIndex) = p_vValue
End If
End If
End If
Done:
Exit Sub
ErrorHandler:
Call Me.RaiseError(Error)
End Sub
Highlighted “«/span>=” should be “>=“.
Thanks!