Using the AfterUpdate event on a dynamically created Textbox

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
Hi!

I have a close made with the code below but the AfterUpdate event does not seem to exist for a dynamically created textbox. Am I doing something wrong because the change event works perfectly fine.

Thanks

Code:
Public WithEvents New_TextBox As MSForms.TextBox

Public Sub New_TextBox_Change()

    Msgbox "test"

End Sub

Sub CreateTextbox(FRAME As MSForms.FRAME, Text_Caption As String, Top_Position As Long, Left_Position As Long, Width_Value As Integer, Height_Value As Integer, Visible_Value As Boolean, TagValue As String, ColorChoice As Long, BackColorChoice As Long, Transparency As Boolean, IsLocked As Boolean, SpecialEffectSetting As Long)

    Dim Control As MSForms.TextBox
    
    Set Control = FRAME.Controls.Add("Forms.Textbox.1", , True)
       
    With Control
        .Width = Width_Value
        .Left = Left_Position
        .Top = Top_Position
        .ForeColor = ColorChoice
        .Height = Height_Value
        .Tag = TagValue
        
        'Excel glitch but this is the fix
        .MultiLine = False 'Set MultiLine to False
        .WordWrap = False  'Set WordWrap to False
      
        .Text = Text_Caption
        If Transparency = True Then
            .BackStyle = fmBackStyleTransparent
        Else
            .BackColor = BackColorChoice
        End If
        If IsLocked Then
            .Locked = True
        End If
        .SpecialEffect = SpecialEffectSetting
        
        'Excel glitch but this is the fix
        .MultiLine = True  'Set Multiline to True
        .WordWrap = True   'Set WordWrap to True
        
        .Visible = Visible_Value
        
        'If Visible_Value = True Then .SetFocus
    End With
    
    'Update Counter
    Control_Count = Control_Count + 1

    'Assign New Control to Collection
    NewControls.Add Control, Control.Name
    NewControlsTag.Add "", Control.Name
    
    Set DynamicControl = New DynamicControls
    Set DynamicControl.New_TextBox = Control
    NewControlsEvent.Add DynamicControl, Control.Name

End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Take a look at post#6 and #9 in this thread :
 
Upvote 0
Take a look at post#6 and #9 in this thread :

Wow impressive. Its crazy how well you know windows API. Seems like there is nothing that cant be done!
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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