A ComboBox question

G

Geoff Cox

Hello,

The following code is used to fill a CoomboBox. The user makes the
correct selection and then moves on to the next slide.

At the moment the first ComboBox has the number 2 in it, the second
the number 1 in it and the third the number 2.

How do I make sure that the boxes are empty before a macro is run to
populate the boxes with the various possible answers?

Cheers

Geoff

Private Sub Initialize()

If ComboBox1.ListCount = 5 Then GoTo Check
ComboBox1.AddItem "Select"
ComboBox1.AddItem "charges"
ComboBox1.AddItem "costs"
ComboBox1.AddItem "revenue"
ComboBox1.AddItem "price"


Check:
ComboBox1.Style = fmStyleDropDownList
ComboBox1.BoundColumn = 0
ComboBox1.ListIndex = 0

End Sub

Private Sub ComboBox1_Click()
Select Case ComboBox1.Value
Case 0
Label1.Caption = "What's your Answer?"
Case 1
Label1.Caption = "No, try again."
Case 2
Label1.Caption = "Well done, this is the associated word."
Case 3
Label1.Caption = "No, try again."
Case 4
Label1.Caption = "No, try again."


End Select
End Sub


Sub object_mouse_over()

Initialize

End Sub
 
B

Bill Dilworth

Is this the line of code you are looking for?

ComboBox1.ListIndex = -1

You will need to work it into your solution, but this should point you in
the right discovery direction.

--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Geoff Cox

Is this the line of code you are looking for?

ComboBox1.ListIndex = -1

You will need to work it into your solution, but this should point you in
the right discovery direction.

Bill,

Thanks for the idea - problem is I cannot find any relevant text using
Google! Could you say how this can be used?!

Cheers

Geoff
 
B

Bill Dilworth

So ....

.... knowing that you asked for the code to ensure the combobox was clear
before processing, and ....

.... that the code seems to addresses the list index (selected line) of a
combo box ...

.... where did you try to place the line of code?


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Geoff Cox

So ....

... knowing that you asked for the code to ensure the combobox was clear
before processing, and ....

... that the code seems to addresses the list index (selected line) of a
combo box ...

... where did you try to place the line of code?

Bill,

I have tried placing your line in various places but not understanding
what ComboBox1.ListIndex = -1 is meant to do I am totally at a loss
and simply guessing!

Just a little info would help!

Cheers

Geoff
 
B

Bill Dilworth

Sub ComboBoxSetup()
'call this sub directly via action setting on a _
shape that lies behind and slightly larger _
than the combo box

'Populate list if it isn't
With ComboBox1
If .ListCount <> 5 Then
.Clear
.AddItem "Select"
.AddItem "charges"
.AddItem "costs"
.AddItem "revenue"
.AddItem "price"
End If

'Make sure selection is blanked
.ListIndex = -1
Label1.Caption = "What's your answer?"

End With
End Sub


Private Sub ComboBox1_Click()
'Show answer
With Label1
If ComboBox1.ListIndex = 2 Then
.Caption = "Well done, this is the associated word."
Else
.Caption = "No, try again."
End If
End With
End Sub
 
G

Geoff Cox

Sub ComboBoxSetup()
'call this sub directly via action setting on a _
shape that lies behind and slightly larger _
than the combo box

'Populate list if it isn't
With ComboBox1
If .ListCount <> 5 Then
.Clear
.AddItem "Select"
.AddItem "charges"
.AddItem "costs"
.AddItem "revenue"
.AddItem "price"
End If

'Make sure selection is blanked
.ListIndex = -1
Label1.Caption = "What's your answer?"

End With
End Sub


Private Sub ComboBox1_Click()
'Show answer
With Label1
If ComboBox1.ListIndex = 2 Then
.Caption = "Well done, this is the associated word."
Else
.Caption = "No, try again."
End If
End With
End Sub

Thanks Bill - will try this out.

Cheers

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

using combobox for drop down menu? 10
Combo Box 13
list box remove item by combobox 4
ComboBox with VBA 0
excel sheet with control combobox 3
ComboBox Help 1
Combo Boxes 5
How to Add items to a ComboBox list 11

Top