Run Time control events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a form with a frame. In that frame, I add TextBox controls during run time.
Question: how can I trap the change event of these controls which were added at runtime

Thanks in advanc

Christof
 
wrap the control in a class which handles the event. add
a new instance of the class for each control and add it
to a collection.

Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Hi,

I have a form with a frame. In that frame, I add TextBox controls during run time.
Question: how can I trap the change event of these
controls which were added at runtime?
 
I've create a class holding two textboxes as

Public WithEvents SystemBox As TextBox
Public WithEvents DescriptionBox As TextBox

However, I get the message 'object does not source automation events'

Where did I go wrong?
Christof
 
Christof,

Both the Excel and the MSForms library contain an object name
TextBox. The Excel TextBox does not source events, while the
MSForms TextBox does. Because the Excel library appears in the
References list before the MSForms library, the compiler is using
the Excel TextBox when you declare a variable As TextBox.

You need to qualify the TextBox with the MSForms library name.
E.g.,

Public WithEvents SystemBox As MSForms.TextBox


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


message
news:[email protected]...
 
Hi Christof,
I've create a class holding two textboxes as

Public WithEvents SystemBox As TextBox
Public WithEvents DescriptionBox As TextBox

However, I get the message 'object does not source automation events'

Where did I go wrong?

You need to declare them As MSForms.TextBox, as Excel has its own
TextBox object.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk
 
Back
Top