Passing a comboBox to a sub

C

cmpcwil2

I am trying to pass a comboBox to a sub to carry out sort on the items,
but I am having difficulty in doing this using the following...

Sub BubbleSortCombo(ByRef myCombo As MSForms.ComboBox)

Then call the sub()

BubbleSortCombo("ComboBox 1")
returns a type mismatch error I know it is to do with the different
type of control but can't figure it out. I am using a ComboBox from the
VB toolbox.

Can anyone help?
 
G

Guest

I think your problem might be that when you pass "ComboBox 1" you are not
actually passing it the combo box, you are passing the string "ComboBox 1"

Try calling the sub this way:

BubbleSortCombo(ComboBox1)

(Control names, like any variable name, cannot include spaces.)

Hopefully this helps.
 

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

Top