Option Explicit Private y As Long Private i As IntegerPrivate Sub Command1_Click() Dim Shape As Shape Set Shape = Me.Controls.Add("VB.Shape", "Shape" & i) With Shape .Visible = True .Move 0, y, 500, 500 End With i = i + 1 y = y + 450End Sub
'需要设计时将 Commad1 的 Index 属性设置为 0Static n As Integern = n + 1 Load Command1(n) Command1(n).Top = Command1(0).Top + (n Mod 6) * (Command1(0).Height + 80) Command1(n).Left = Command1(0).Left + (n \ 6) * (Command1(0).Width + 160)Command1(n).Caption = "Command" & n + 1 Command1(n).Visible = True
Private y As Long
Private i As IntegerPrivate Sub Command1_Click()
Dim Shape As Shape
Set Shape = Me.Controls.Add("VB.Shape", "Shape" & i)
With Shape
.Visible = True
.Move 0, y, 500, 500
End With
i = i + 1
y = y + 450End Sub
Load Command1(n)
Command1(n).Top = Command1(0).Top + (n Mod 6) * (Command1(0).Height + 80)
Command1(n).Left = Command1(0).Left + (n \ 6) * (Command1(0).Width + 160)Command1(n).Caption = "Command" & n + 1
Command1(n).Visible = True