ok check this out... with a combo box you have 3 styles... 2 of these are dropdown and the 3rd is a nondrop down.. well im focusing on style 2 here the style that is a dropdown but you are NOT allowed to write in it.. but yes have text shown on it when it loads up.. example of why you would want to use this code?
perhaps you want a pull down box with "Chose State" or something and once they chose something "Chose State" will no longer be available... well here we go..
'put in combo click propertie Private Sub Combo1_Click() Static once 'makes it so the value will stay the same until change again.
If once <> "yes" Then 'checks if once has been activated. If Combo1.Text <> "Enter Name" Then 'checks if the text is the same text you only wanna display once. Combo1.RemoveItem (0) 'if so it removes it. once = "yes" 'sets once to tell it has run already this way it doesnt delete the first thing in the box every time the box is pulled down. End If End If
'put in form load Private Sub Form_Load()
With Combo1 'adds sample stuff. .AddItem "Enter Name" .AddItem "line1" .AddItem "line2" .AddItem "line3" .AddItem "line4" .AddItem "line5" End With
Combo1.ListIndex = 0 'makes it so the text you want to show is selected when program is ran.
'note is is important that the thing you want to be deleted is the first thing in the list.. if not.. then you listindex's need to be changed to the index number it is.
and that is how i do it.. hope you people enjoy my first FAQ!!