Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Combo box question

I have 3 items in my combobox  :Banana,orange,mango
when the program run for the first time the Banana will be selected in the combobox ,now i have a listbox right below the combo, what i need the program to do is, whenener user select item from combo the content of the listbox will be cleared (here i only allow user to select existing item from combobox), thank you
0
indra_eva2002
Asked:
indra_eva2002
1 Solution
 
DeAnCommented:
this will clear the listbox named List1

Dim i As Integer
i = List1.ListCount - 1
While i >= 0
    List1.RemoveItem i
    i = i - 1
Wend

is that what you mean?
0
 
supunrCommented:
private sub Form_Load()
    Combo1.AddItem "Banana"
    Combo1.AddItem "Orange"
    Combo1.AddItem "Mango"
    ' Select first item
    Combo1.ListIndex = 0
    Combo1.Style = 2 ' Dropdown list
End Sub

Private Sub Combo1_Click()
    List1.Clear
    if (Combo1.Text = "Banana") then
        List1.AddItem "Banana Item1"
        List1.AddItem "Banana Item2"
        List1.AddItem "Banana Item3"
        ' etc.
    elseif (Combo1.Text = "Orange") then
        List1.AddItem "Orange Item1"
        List1.AddItem "Orange Item2"
        List1.AddItem "Orange Item3"
        ' etc.
    Elseif (Combo1.Text = "Mango") then
        List1.AddItem "Mango Item1"
        List1.AddItem "Mango Item2"
        List1.AddItem "Mango Item3"
        ' etc.
    end if
    list1.listindex = 0 ' select first item
End Sub

Good LUck!
0
 
indra_eva2002Author Commented:
Excellent, thanks SUPUNR for solving my problem.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now