Run Time control events

C

Christof DB

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
 
P

Patrick Molloy

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?
 
C

Christof DB

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
 
C

Chip Pearson

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]...
 
S

Stephen Bullen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top