Pass a form Listbox as an object

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I'm trying to pass a vba forms listbox as an object.

Scenario: I have a form with two populated listboxes. When I click on one,
I want to perform an action based on the value selected. The action is
independent of which listbox is selected, but needs to know somethings about
the listbox activated.

How do I pass the listbox object as an argument?

Thanks for the help.
Brian
 
Brian,

This example should show you

Private Sub ListBox1_Click()
WhichListbox Me.ListBox1
End Sub

Private Sub ListBox2_Click()
WhichListbox Me.ListBox2
End Sub

Sub WhichListbox(LB As msforms.ListBox)
MsgBox LB.Name
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
That was it!!!

Thanks,

Funny thing is my test code was doing just what you demonstrated...
msgbox-ing the lb name.

Anyway.... I'll remember this one.

B
 

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

Back
Top