ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox added to Form at runtime is too small, can't control size andchange event won't trigger (https://www.excelbanter.com/excel-programming/421121-textbox-added-form-runtime-too-small-cant-control-size-andchange-event-wont-trigger.html)

RCGUA

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


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 that is typed into 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

Office_Novice

Textbox added to Form at runtime is too small, can't control size
 
Try removing this line ctrl.AutoSize = True


"RCGUA" wrote:



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 that is typed into 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


RCGUA

Textbox added to Form at runtime is too small, can't control size
 
On Dec 10, 2:24*pm, Office_Novice
wrote:
Try removing this line *ctrl.AutoSize = True

Thanks for your reply. I just tried removing that line and the box
still remains small and only displays a few words of text and typing
in the box still doesn't trigger the change event (which can be used
to run code to re-size the box).

"RCGUA" wrote:

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 that is typed into 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- Hide quoted text -


- Show quoted text -




All times are GMT +1. The time now is 08:06 AM.

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