In order to be able to remove controls from a Form
, when triggered by a ComboBox
, you will need to execute the deletion operation through a Timer
.
So, when the ComboBox
event is to be triggered, start (enable) a Timer
that when triggered, calls the subroutine that you wanted to call in the first place.
This is how the code would look like:
Private Sub MyCombo_Change()
MyTimer.Enabled = False
MyTimer.Enabled = True
End Sub
Private Sub MyTimer_Timer()
MyTimer.Enabled = False
DeleteMenuItems
End Sub
Private Sub DeleteMenuItems()
Dim i As Intener
For i = mnuTCategory.Count - 1 To 1 Step -1
Unload mnuTCategory(i)
Next
End Sub