
Combobox control, change event
Use the Click Event and check the combo's ListIndex value to tell what was
Selected.
If you need to be able to tell if the value changed you should use a form
level variable to track the value of the ListIndex.
Option Explicit
Private lngLastSelected As Long
Private Sub Form_OnLoad()
lngLastSelected = -1 'Nothing selected yet
End Sub
Private Sub cboMyCombo_Click()
If lngLastSelected <> cboMyCombo.ListIndex Then ' selection changed
' Do something
lngLastSelected = cboMyCombo.ListIndex 'update the last selection
End If
End Sub
Quote:
> Hi there,
> I'm a newbie here, please bear with me for a sec and at least point me
> in the right direction. I am using VB4.0 and have a ComboBox control. I
> need some action to take place when the user changes the selection (with
> mouse or keys) but don't know which event to use. I tried
> using the _change() event, with no luck, it didn't get called.
> Is there something I have to do to make it work? Or what's the
> correct event to use?
> Thanlks,
> - Roberto
> --
> Tufts University __/__, uucp:
---------------------------------------------------------------------------
-