ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Time control events (https://www.excelbanter.com/excel-programming/284544-run-time-control-events.html)

Christof DB

Run Time control events
 
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

patrick molloy

Run Time control events
 
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?

Thanks in advance

Christof
.


Christof DB

Run Time control events
 
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

Chip Pearson

Run Time control events
 
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


"Christof DB" wrote in
message
...
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




Stephen Bullen

Run Time control events
 
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


Christof DB

Run Time control events
 
Oops, forgot about that. Thanks for the info and a nice weekend

Christof


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com