Is there a way where i can check the items that have been added to the combo box before?( without any looping)...like
If combo.( ? ) ="xxx" then
..
thanks
Printable View
Is there a way where i can check the items that have been added to the combo box before?( without any looping)...like
If combo.( ? ) ="xxx" then
..
thanks
Are you trying to find out if a certain value is already in the combobox without having to loop?
yes you are rite..(value = the items that have been added in)...any simplier methods (using ny properties of the combo box) to check...:)
I added some extra stuff so that you can change it to do partial or exact searches on either a listbox or a combobox.VB Code:
Option Explicit Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" _ (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) As Long Private Const LB_FINDSTRINGEXACT = &H1A2 Private Const CB_FINDSTRINGEXACT = &H158 Private Const CB_FINDSTRING = &H14C Private Const LB_FINDSTRING = &H18F Private Sub Command1_Click() Dim lngRetVal As Long lngRetVal = SendMessageString(Combo1.hWnd, CB_FINDSTRINGEXACT, -1&, strSomeValue) If lngRetVal > -1& Then ' It's already in the list and lngRetVal is the ListIndex Else ' It's not in the list End If End Sub
..wow..its a bit difficult for me to understand though...but will give a try...thanks alot..
Let me know if you have any questions.