When using the control with a SORTED bar option, you cannot add an item; the function fails on the first call because the item index is zero while the UDT array lower bound is 1. Please see the fix below which should be added to the fItemAdd function:
If Not IsMissing(KeyBefore) Then
...
Else
ReDim Preserve m_tBar(lBarIndex).tItem( _
1 To m_tBar(lBarIndex).lItemCount + 1) As tBarItem
If (m_tBar(lBarIndex).bSorted) And Len(Caption) > 0 Then
' find the position:
For i = 1 To m_tBar(lBarIndex).lItemCount
If (StrComp(Caption, _
m_tBar(lBarIndex).tItem(i).sCaption, _
vbTextCompare) <= 0) Then
lIndex = i
Exit For
End If
Next i
If (lIndex > 0) Then
' Shift everything from lIndex to end down:
For i = m_tBar(lBarIndex).lItemCount To lIndex Step -1
LSet m_tBar(lBarIndex).tItem(i + 1) = _
m_tBar(lBarIndex).tItem(i)
Next i
Else
' the following line will return zero on an empty,
‘ sorted bar:
lIndex = m_tBar(lBarIndex).lItemCount
' Add these lines:
If lIndex = 0 Then
lIndex = 1
End If
' end add.
End If
m_tBar(lBarIndex).lItemCount = m_tBar(lBarIndex).lItemCount + 1
Else
...
Yaron Lavi,
Applications Project Manager
SigValue Technologies.
|