Here's an example:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Public Sub Form_Load()
Const INITIAL_X = 10
Const INITIAL_Y = 10
Const BUTTON_WIDTH = 100
Const BUTTON_HEIGHT = 30
Dim i As Integer
Dim buttons(5) As CommandButton
For i = 0 To 5
buttons(i) = New CommandButton()
buttons(i).Caption = "button " & i
buttons(i).Top = INITIAL_Y + (BUTTON_HEIGHT * i)
buttons(i).Left = INITIAL_X
buttons(i).Width = BUTTON_WIDTH
buttons(i).Height = BUTTON_HEIGHT
Me.add(buttons(i))
Next
End Sub
|
I hope it will be useful for