#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default WithEvents


withevents needs to know which events can be triggered.
and that's diffrent for a label opposed to a combobox.


--
Dnereb
------------------------------------------------------------------------
Dnereb's Profile: http://www.excelforum.com/member.php...o&userid=26182
View this thread: http://www.excelforum.com/showthread...hreadid=397385

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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" wrote in message
...
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
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
Using Class, WithEvents and auto-instanciating Tetsuya Oguma[_2_] Excel Programming 0 September 5th 03 03:22 AM
Can't dynamically add withevents OptionButton to worksheet onedaywhen Excel Programming 6 August 27th 03 09:11 AM


All times are GMT +1. The time now is 09:42 AM.

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"