Avoiding Bound Controls
SelectItem - a brief description...
Select item expands on ItemIndex by actually selecting the item in the list before exiting. Apart from this, it is exactly the same. This function will generate a Click event so you can respond to the selection change as normal.
Sub SelectItem (lstX As Control, ByVal sSelect As String)
Dim iPos As Long
' Search for the exact string in the ListBox or Combo
If TypeOf lstX Is ComboBox Then
iPos = BIND_SendMessageString(lstX.hWnd, BIND_CB_FINDSTRINGEXACT, -1, sSelect)
Else
iPos = BIND_SendMessageString(lstX.hWnd, BIND_LB_FINDSTRINGEXACT, -1, sSelect)
End If
' Select the item requested. If the item was not found
' -1 will be returned which clears the current
' selection, so we do that too
lstX.ListIndex = iPos
End Sub
![]()