+ Reply to Thread
Results 1 to 3 of 3

Pass a form Listbox as an object

  1. #1
    Brian
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Brian
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1