Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then 'KeyAscii=13 '表示输入后按回车键
For i=0 To Combo1.ListCount-1
If Combo1.Text=Combo1.List(i) Then
msgbox "输入项已在组合框中"
Exit Sub
End if
Next i
msgbox "已成功添加输入项"
Combo1.AddItem Combo1.Text
End if
End Sub
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_SHOWDROPDOWN = &H14F
Private Sub Command1_Click()
Call SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
End Sub