This code will allow you to add controls at runtime. The first example allow
you to add 5 controls. The second example will all you to add as many as you
want. In order to add controls at runtime you must set the index property of the control to zero(0). So add a command button and set the index property to 0.
=================================================================
Private Sub Command1_Click(Index As Integer)
Dim i, j As Integer
For i = 1 To 4
Load Command1(i)
Command1(i).Visible = True
Command1(i).Top = Command1(i - 1).Top + Command1(i - 1).Height
Next
End Sub
===================== Example Two ===============================
Option Explicit
Dim cmdControl() As Integer 'Hold how many txtboxes have been added
Dim cmdCount As Integer 'This holds the txt number
Private Sub Command1_Click(Index As Integer)
Dim i, j As Integer
Counter
ReDim Preserve cmdControl(cmdCount)
i = cmdCount
j = cmdCount - 1
Load Command1(i)
Command1(i).Visible = True
Command1(i).Top = Command1(j).Top + Command1(j).Height
End Sub
Public Sub Counter()
cmdCount = cmdCount + 1
End Sub