As soosn as you select or deselect items in listbox, it will generate click event.
So try to declare a global boolean variable for detecting if the command button is pressed.
Like this;
VB Code:
Dim bButtonClicked As Boolean Private Sub Command1_Click() bButtonClicked = True For i = 0 To lst_itm_cat.ListCount - 1 If lst_itm_cat.Selected(i) = True Then lst_itm_cat.Selected(i) = False Next bButtonClicked = False End Sub Private Sub Form_Load() bButtonClicked = False End Sub Private Sub lst_itm_cat_Click() If bButtonClicked Then Exit Sub 'Your code for ListBox Click Event End Sub




Reply With Quote