Hi,
a syntax that makes Userform controls looks something like this :
Code
Private Sub UserForm_Initialize()
Dim i As Integer, j As Integer
Dim k As Integer, m As Integer
Dim n As Integer, o As Integer
Dim myControl As Control
Const hIncrement As Integer = 5
Const wIncrement As Integer = 10
' height = 18
'width = 72
n = Me.Height / (18 + hIncrement)
o = Me.Width / (72 + wIncrement)
m = wIncrement
For i = 1 To (o - 1)
k = 2 * hIncrement
For j = 1 To (n - 2)
Set myControl = Me.Controls.Add("Forms.Textbox.1", , True)
With myControl
.Top = k
.Left = m
.Height = 18
.Width = 72
k = j * (hIncrement + .Height) + (2 * hIncrement)
End With
Next j
m = i * (wIncrement + myControl.Width) + wIncrement
Next i
Set myControl = Me.Controls.Add("Forms.Commandbutton.1", , True)
With myControl
.Height = 50
.Width = 50
.Left = Me.Width - .Width - (2 * wIncrement)
.Top = (Me.Height / 2) - .Height
.BackColor = vbBlue
.Caption = "CONSOLE"
.ForeColor = vbWhite
End With
End Sub
Display More
I'd like to add Click event to a commandbutton.
Any suggestions ?