I am trying to create textboxes on userform on runtime and this is the code
Code: Select all
Private Sub UserForm_Initialize()
Dim ctl As Control, sWord As String, xLen As Long, i As Long
sWord = "Hello World"
xLen = Len(sWord)
For i = 1 To xLen
Set ctl = Me.Controls.Add("Forms.TextBox.1", "ctl", True)
With ctl
.Top = 20
.Left = ((i - 1) * 20) + 20
.Height = 30
.Width = 25
.Font.Size = 14
.TextAlign = fmTextAlignCenter
.Text = Mid(sWord, i, 1)
End With
Next i
End Sub
I mean as for the space to take the same height and width on userform but no textbox at this point.
And how can I adjust the width of the userform according to the created textboxes?
I noticed also that aligning text to center doesn't work properly ..!