Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_ADDSTRING = &H143
Private Const CB_SETITEMDATA = &H151
Private Sub cmdComboAPI_Click()
Dim strItemText As String
Dim lngIndex As Long
Dim dblTimer As Double
Dim lngAddIndex As Long
cmbTest.Clear
dblTimer = Timer
For lngIndex = 1 To 5000
strItemText = "item number " & CStr(lngIndex)
lngAddIndex = SendMessage(cmbTest.hWnd, CB_ADDSTRING, 0, ByVal strItemText)
SendMessage cmbTest.hWnd, CB_SETITEMDATA, lngAddIndex, ByVal lngIndex
Next
MsgBox Format(Timer - dblTimer, "0.000") & " seconds"
End Sub
Private Sub cmdComboVB_Click()
Dim strItemText As String
Dim lngIndex As Long
Dim dblTimer As Double
cmbTest.Clear
dblTimer = Timer
For lngIndex = 1 To 5000
strItemText = "item number " & CStr(lngIndex)
cmbTest.AddItem strItemText
cmbTest.ItemData(cmbTest.NewIndex) = lngIndex
Next
MsgBox Format(Timer - dblTimer, "0.000") & " seconds"
End Sub
|