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..
[color green]'put in combo click propertie[/color]
[color blue]Private Sub[/color] Combo1_Click()
[color blue]Static[/color] once [color green]'makes it so the value will stay the same until change again.[/color]
[color blue]If[/color] once [color blue]<>[/color] "yes" [color blue]Then[/color] [color green]'checks if once has been activated.[/color]
[color blue]If[/color] Combo1.Text [color blue]<>[/color] "Enter Name" [color blue]Then[/color] [color green]'checks if the text is the same text you only wanna display once.[/color]
Combo1.RemoveItem (0) [color green]'if so it removes it.[/color]
once = "yes" [color green]'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.[/color]
[color blue]End If[/color]
[color blue]End If[/color]
[color blue]End Sub[/color]
[color green]'put in form load[/color]
[color blue]Private Sub[/color] Form_Load()
Combo1.ListIndex = 0 [color green]'makes it so the text you want to show is selected when program is ran.[/color]
[color green]'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. [/color]
[color blue]End Sub[/color]
and that is how i do it.. hope you people enjoy my first FAQ!!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.