+ Reply to Thread
Results 1 to 4 of 4

can I make a general object event procedure?

  1. #1
    Wazooli
    Guest

    can I make a general object event procedure?

    Is there a way to make event procedures generic? For example, if I create
    and populate a list or combo box via code, can I pass the address of the
    created box to a _change() procedure?

    wazooli

  2. #2
    Tom Ogilvy
    Guest

    Re: can I make a general object event procedure?

    Not generally. You can make an create a class and assign that class to
    multiple objects, then define you events in that class.

    See John Walkenbach's site for an example.
    http://j-walk.com/ss/excel/tips/tip44.htm
    Handle Multiple UserForm Buttons With One Subroutine

    Written for a userform and commandbuttons, the approach will work for any
    activeX control and can be for a userform or a worksheet.

    --
    Regards,
    Tom Ogilvy


    "Wazooli" <[email protected]> wrote in message
    news:[email protected]...
    > Is there a way to make event procedures generic? For example, if I create
    > and populate a list or combo box via code, can I pass the address of the
    > created box to a _change() procedure?
    >
    > wazooli




  3. #3
    Wazooli
    Guest

    Re: can I make a general object event procedure?

    Yeah - he talks about it in his book. I will muck about with this. Don't be
    surprised if i am back here tomorrow with questions.

    "Tom Ogilvy" wrote:

    > Not generally. You can make an create a class and assign that class to
    > multiple objects, then define you events in that class.
    >
    > See John Walkenbach's site for an example.
    > http://j-walk.com/ss/excel/tips/tip44.htm
    > Handle Multiple UserForm Buttons With One Subroutine
    >
    > Written for a userform and commandbuttons, the approach will work for any
    > activeX control and can be for a userform or a worksheet.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Wazooli" <[email protected]> wrote in message
    > news:[email protected]...
    > > Is there a way to make event procedures generic? For example, if I create
    > > and populate a list or combo box via code, can I pass the address of the
    > > created box to a _change() procedure?
    > >
    > > wazooli

    >
    >
    >


  4. #4
    NickHK
    Guest

    Re: can I make a general object event procedure?

    Wazooli,
    Not sure if this is what you mean, but you can pass the object (or rather a
    pointer to it ?) to a sub/function.

    Private Function a_change(MyObject as Object) as long
    'Decide what to do based on the type of object
    If MyObject Is ComboBox Then.....


    You could call this from any objects' event procedure
    RetVal=a_change(ThisObject)

    NickHk

    "Wazooli" <[email protected]> wrote in message
    news:[email protected]...
    > Is there a way to make event procedures generic? For example, if I create
    > and populate a list or combo box via code, can I pass the address of the
    > created box to a _change() procedure?
    >
    > wazooli




+ 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