使用VB编程如何实现这样的功能:在程序运行过程中动态创建按钮

解决方案 »

  1.   

    动态创建Commond控件:
    Dim objCommond   As Object      '文本编辑框
    Set objCommond   = Controls.Add("VB.Commond", "CommondName", Me)
      

  2.   

    Dim WithEvents ctlCommand As VB.CommandButtonPrivate Sub Form_Load()
    Set ctlCommand = Controls.Add("VB.CommandButton", "ctlCommand1", Me)
    '设置CommandButton的位置和尺寸ctlCommand = 400 + 200
    ctlCommand.Left = 20'设置CommandButton的标题
    ctlCommand.Caption = "点击"
    '使CommandButton可见
    ctlCommand.Visible = TrueEnd Sub