Option Explicit
Dim m_bt() As Object
Private Sub Form_Load()
Dim bt As Object, i As Integer, cl As Object
ReDim m_bt(2)
For i = 0 To UBound(m_bt)
Set bt = Controls.Add("VB.CommandButton", "bt" & i)
bt.Visible = True
bt.Move (ScaleWidth - bt.Width) / 2, bt.Height * (i + 1)
Set cl = New clsBT
Set cl.Button = bt
If i = UBound(m_bt) Then
bt.Tag = "#"
bt.Caption = "Close"
Set cl.OwnerForm = Me
Else
bt.Caption = "Button " & i + 1
End If
Set m_bt(i) = cl
Next i
End Sub
|