Textbox added to Form at runtime too small, can't control size andchange event won't trigger

R

RCGUA

I have Form and when the user clicks CommandButton4 a textbox is added
to the form with the code below. When I type in the textbox it
resizes itself really small and you can only view a small amount of
the text typed into the box. Also, when I type in the box the change
event does trigger the msgbox. Does anyone know how to make this
textbox resize so the user can see all the text typed in the box?

Private Sub CommandButton4_Click()
Dim ctrl As msforms.TextBox
With Me
Set ctrl = .Controls.Add("forms.textbox.1", "txt1", True)
ctrl.Left = 20
ctrl.Top = 50
ctrl.AutoSize = True
ctrl.MultiLine = True
ctrl.WordWrap = True
ctrl.Visible = True
End With
End Sub

Private Sub txt1_change()
MsgBox "txt1 has changed"
End Sub
 
S

Shane Devenshire

Hi,

Rather than create the textbox on the fly, why not create it ahead of time
and then hide it. When the user clicks their button display the textbox.
 
R

RCGUA

Hi,

Rather than create the textbox on the fly, why not create it ahead of time
and then hide it.  When the user clicks their button display the textbox.  

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire
Thanks for your reply. The user is allowed to create up to 99 text
boxes on the form so that is why I was hoping to create them on the
fly rather than create 99 invisible textboxes. However, if the group
knowledge is that this is the only way to do, then I will create 99
invisible textboxes.
 

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