Consulting

Results 1 to 4 of 4

Thread: Trapping UserForm Events In A Seperate Class

  1. #1

    Trapping UserForm Events In A Seperate Class

    I have built up a userform which contains a multipage and frame inside it.

    I want to set textbox values and write action handlers in a seperate class so I can keep things clean.

    I have tried to capture the events raised from the userform directly with no success.

    Do I have to trap the events for each control I am interested in explicitly or can I just do: UserForm.myButton_click.

    I also have tried this :

    WithEvents eventIdTestBoxListener As TextBox
    But I get a object does not support automation events error.

    Please help!!!

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Try putting this in a class module
    [VBA]Public WithEvents myBox As msforms.TextBox
    [/VBA]

  3. #3
    Yup - Thats it

    Awesome - Thanks

    Is there a way of getting a class to trap all events which happen on a form including all its children?

    Put another way if you have a user form and two text boxes on there how can I trap all events I want too without explcitly asking for events of each component

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    The class would have to have a property for each type of control or you could have it use msforms.Control which only has 4 propreties.

Posting Permissions

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