Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Pass a form Listbox as an object

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Pass a form Listbox as an object

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)


"Brian" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Pass a form Listbox as an object

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



"Bob Phillips" wrote in message
...
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)


"Brian" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass string value to another form yangyh[_5_] Excel Programming 1 September 11th 05 10:01 AM
How do I pass an array to a listbox? Titus A Ducksass - AKA broken-record Excel Programming 4 March 23rd 05 07:20 PM
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM
How to pass ListBox into a Sub? RADO[_3_] Excel Programming 2 November 16th 03 08:22 PM
How to pass valve in combobox object to cell chanon Excel Programming 3 October 15th 03 04:25 AM


All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"