+ Reply to Thread
Results 1 to 3 of 3

WithEvents

  1. #1
    Ronin
    Guest

    WithEvents

    Group,

    How is it that if i specify the below:

    Public WithEvents mTestCtl As MSForms.TextBox

    it will work fine, but if specified as MSForms.Control, it errors out with:

    Run-time error '459':

    Object or class does not support the set of events

    please review the code below.

    Public WithEvents mTestCtl As MSForms.Control
    Sub SetControl(ctl As MSForms.Control)
    Set mTestCtl = ctl '<-this is where it errors out
    End Sub
    Private Sub mTestCtl_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    MsgBox mTestCtl.Value
    End Sub


    Please help.


    Thanks in advance.


    Ronin

  2. #2
    Registered User
    Join Date
    08-11-2005
    Location
    Netherlands Waddinxveen
    Posts
    81
    withevents needs to know which events can be triggered.
    and that's diffrent for a label opposed to a combobox.

  3. #3
    Chip Pearson
    Guest

    Re: WithEvents

    A Control is a generic control. It can be set to any of the
    controls in the MSForms library. Each of these controls has a
    different set of events, and the compiler doesn't know what type
    of control that variable will be set to, so it cannot generate
    event code.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Ronin" <[email protected]> wrote in message
    news:[email protected]...
    > Group,
    >
    > How is it that if i specify the below:
    >
    > Public WithEvents mTestCtl As MSForms.TextBox
    >
    > it will work fine, but if specified as MSForms.Control, it
    > errors out with:
    >
    > Run-time error '459':
    >
    > Object or class does not support the set of events
    >
    > please review the code below.
    >
    > Public WithEvents mTestCtl As MSForms.Control
    > Sub SetControl(ctl As MSForms.Control)
    > Set mTestCtl = ctl '<-this is where it errors out
    > End Sub
    > Private Sub mTestCtl_Exit(ByVal Cancel As
    > MSForms.ReturnBoolean)
    > MsgBox mTestCtl.Value
    > End Sub
    >
    >
    > Please help.
    >
    >
    > Thanks in advance.
    >
    >
    > Ronin




+ 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