请问如何用代码实现增加一个shape或command.
我现在在form中放一个按纽. 用户每点击一次. 可以在FORM上增加一个按键或SHAPE. 
另外. 如何用代码实现SHAPE和按键按一个设置的规矩排列?

解决方案 »

  1.   

    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
      

  2.   

    '需要设计时将 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