encapsulate form with event inside the class

amigos.pl

New Member
Joined
Jul 2, 2009
Messages
31
hello

so I have this form which I populate with text boxes on runtime

To be alble to detect when user made change to the text box I am passing them withevents to the class and I want to handle the event inside the class.

So this is what I have:

Inside my class (cFakePositionTextBoxWrapper)

' declaration
Private WithEvents m_oTextBox As MSForms.TextBox

' pass text box
Public Sub AddTextBox(oTextBox As MSForms.TextBox)
Set m_oTextBox = oTextBox
End Sub

' capture event
Private Sub m_oTextBox_Change()

End Sub

And that's what I have in the form code:

Dim oTextBox As MSForms.TextBox

' add the text box
Set oTextBox = frmFakePosition.fraFakePositionsEdit.Controls.Add("Forms.TextBox.1", m_sCONTROL_POSITION_PREFIX & "_" & i & "_" & j, True)

' textbox wrapper
Dim oFakePositionTextBoxWrapper As cFakePositionTextBoxWrapper
Set oFakePositionTextBoxWrapper = New cFakePositionTextBoxWrapper

' pass text box to the wrapper
oFakePositionTextBoxWrapper.AddTextBox oTextBox



It works fine (i mean it doesnt error) but when I input data into the textbox - event is not captured.

Any ideas what I am doing wrong?

thank you
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
pls ignore this post
it's all working fine
when I created those wrappers I forgot to put them into the dictionary so they all died...

:)
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,790
Members
452,942
Latest member
VijayNewtoExcel

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