Hello
What i want is to display 65 textboxes and 65 labels adjacent to each other in 3 or 5 columnar way on the userform at run time.
Textbox and Label Top Position starts from 144
so when used the following in below code for both controls textbox and label .Top = 144 * i * 1 the gap between each Label and Textbox is huge and looks bad.
How can i get the perfect gap between each label and Textbox respectively below each other and also perfect gap for columnar representation on userform.
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
......so on
Thankx NimishK
What i want is to display 65 textboxes and 65 labels adjacent to each other in 3 or 5 columnar way on the userform at run time.
Textbox and Label Top Position starts from 144
so when used the following in below code for both controls textbox and label .Top = 144 * i * 1 the gap between each Label and Textbox is huge and looks bad.
How can i get the perfect gap between each label and Textbox respectively below each other and also perfect gap for columnar representation on userform.
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
Label TextBox Label TextBox Label TextBox
......so on
Code:
Private Sub UserForm_Initialize()
Dim i As Integer
Dim txtbxTopPos As Integer
Dim txtbxGap As Integer
Dim txtB1 As Control
Dim labl As Control
For i = 1 To 65
Set txtB1 = Controls.Add("Forms.TextBox.1")
Set labl = Controls.Add("Forms.Label.1")
With txtB1
.Name = "txtBox" & i
.Height = 15.75
.Width = 126
.Left = 102
.Top = 144 * i * 1
End With
With labl
.Name = "lbl" & i
.Height = 15.75
.Width = 126
.Left = 10
.Top = 144 * i * 1
.BackStyle = 0
.Caption = Sheet1.Cells(1, i).Value
End With
Next i
End Sub
Thankx NimishK
Last edited: