Hi,
I have a form that is dynamically created at runtime. I have assigned the controls to a frame in VBA and also attached a horizontal scrollbar manually to that frame.
How can I control the scrollbar in VBA to appear, when columns of controls added to the frame exceeds 10. If not I want the scrollbar to be invisible?
Please give me a helping hand.
Cheers
prsthlm
Private Sub UserForm_Initialize()
Const cTextBoxHeight As Long = 16
Const cTextBoxWidth As Long = 40
Const cGap As Long = 10
Dim W As Integer
Dim a As Integer
Y = 0
i = 1
l = 90
' Sim() is a global variable and the look of it is like this:
' "0647", 53, 47, "0648", 55, 48, "0649", 65, 59, ... etc
' Each column in the form will be 3 rows of controls
For i = 1 To UBound(Sim) / 3
With Me.Frame1.Controls.Add("Forms.TextBox.1", "TB" & i, True)
.Value = Format$(Sim(Y), "0000")
.Left = l
.Top = 12
.Height = cTextBoxHeight
.Width = cTextBoxWidth
.Locked = True
.Enabled = False
End With
Y = Y + 1
With Me.Frame1.Controls.Add("Forms.TextBox.1", "TB" & i, True)
.Value = Sim(Y)
.Left = l
.Top = 12 + cTextBoxHeight + cGap
.Height = cTextBoxHeight
.Width = cTextBoxWidth
.Locked = True
.Enabled = False
End With
Y = Y + 1
With Me.Frame1.Controls.Add("Forms.TextBox.1", "TB" & i, True)
.Value = Sim(Y)
.Left = l
.Top = 12 + cTextBoxHeight * 2 + cGap * 2
.Height = cTextBoxHeight
.Width = cTextBoxWidth
.Locked = True
.Enabled = False
End With
Y = Y + 1
l = l + cTextBoxWidth + cGap
Next i
End Sub
Display More