eventhandling of dynamically created textboxes

Don Juan Matus

New Member
Joined
Mar 13, 2019
Messages
1
Hello,

In fact I need a list of inputboxes:
- first collumn is with fixed numbering
- second and third collumn should behave like inputboxes for values
- I need 20 rows of it

As the listbox-control doesn't allow user input, I thought of creating
the textboxes dynamically in code and assign them to an array.
The following works - despite that no program break is possible there:

Public controlarry(20, 3) As Object

Sub createTxtBoxexs()
dim i%

for i = 1 to 20
Set controlarry(i) = Worksheets("xyz").OLEObjects.Add("Forms.TextBox.1")
end sub

It is sayed, that I need a class and have to use WithEvents.
But the following is a syntax error:
public withevents txtEvents as Forms.TextBox

How can I process the events of the created TextBoxes?
Can you please give an example for it?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the forum.

It's MSForms.Textbox, not Forms.Textbox.

In my opinion it would be simpler to use one set of textboxes and have them add data to the listbox, but if you want multiple rows there are numerous examples on the forum of how to use classes and withevents.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top