Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Writing code for Events in Class

Hello,

Is it possible to write code for an Event of a control in a class
module?
I wrote a Class Module where I can set a TextBox control. I would like
to have the class to handle the AfterUpdate event of this TextBox
control.

Thanks in advance,

Bart

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Writing code for Events in Class

Bart,

Dim WithEvents SomeVar As SomeControl

NickHK

"Bart" wrote in message
ups.com...
Hello,

Is it possible to write code for an Event of a control in a class
module?
I wrote a Class Module where I can set a TextBox control. I would like
to have the class to handle the AfterUpdate event of this TextBox
control.

Thanks in advance,

Bart



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Writing code for Events in Class

Very nice construction. Thanks NickHK for the tip!

It seems that the AfterUpdate Event is part of the MSForms.Control
Class.
So I'm using the following declaration to get the AfterUpdate event:

Private WithEvents txtControl As MSForms.Control

Now the Events become available in the PickMenu for implemenation.

While running the code with the line where I set the TextBox to this
txtControl, it gives an error:

Run-Time Error '459':
Object or Class does not support the set of events

I don't get it. What does this mean?
I did some playing with implementing Events part of the
MSForms.Textbox Class. That worked correctly.

Bart

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Writing code for Events in Class

Manu,

The AfterUpdate Event doesn't come available when declaring a variable
as MSForms.TextBox Class with Events. I think the MSForms.TextBox
inherits the Event from the MSForms.Control Class.

Why doesn't the AfterUpdate Event becomes available by Inheritance?

Bart






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Writing code for Events in Class

Some events are inherited from the container object, the UserForm here.
Within the events class, you are effectively trapping a
control's events outside of that container, so there is no access to
inherited events (they aren't exposed by that control). AfterUpdate is one
of these.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Bart" wrote in message
ps.com...
Very nice construction. Thanks NickHK for the tip!

It seems that the AfterUpdate Event is part of the MSForms.Control
Class.
So I'm using the following declaration to get the AfterUpdate event:

Private WithEvents txtControl As MSForms.Control

Now the Events become available in the PickMenu for implemenation.

While running the code with the line where I set the TextBox to this
txtControl, it gives an error:

Run-Time Error '459':
Object or Class does not support the set of events

I don't get it. What does this mean?
I did some playing with implementing Events part of the
MSForms.Textbox Class. That worked correctly.

Bart



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Writing code for Events in Class

Thanks Bob! That makes sense.

There's no other way to trap the AfterUpdate Event inherted by the
TextBox outside its Container (UserForm)?

Bart

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Writing code for Events in Class

Don't think so, I use the Change event in the class and AfterUpdate in the
form. A pain, but unavoidable I believe.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Bart" wrote in message
ups.com...
Thanks Bob! That makes sense.

There's no other way to trap the AfterUpdate Event inherted by the
TextBox outside its Container (UserForm)?

Bart



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
Class Events Gareth[_7_] Excel Programming 16 October 5th 05 05:25 PM
Useing Class structures and Events Dan Gardner Excel Programming 2 January 13th 05 08:43 AM
class events stop firing with ADO 2.8 ThankYou_jeff Excel Programming 4 November 14th 04 10:59 AM
Events, Class, Time Editing Dave Excel Programming 1 October 4th 04 11:06 PM
What events can be captured in a Class Module? Tom Ogilvy Excel Programming 4 September 8th 03 05:41 AM


All times are GMT +1. The time now is 01:19 PM.

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"