load txt(1)
set txt(1).container=frame1
txt(1).visible=true

解决方案 »

  1.   

    如果按楼上的理解
    其实在添加的时候,只要txt是从属于Frame的
    那么以后动态添加的txt都是从属于Frame的!
      

  2.   


    ''定义一个控件数组 第一个为 txt(0)load txt(1)                 ''load数组中第2个控件
    set txt(1).container=frame1 ''将该控件数组的容器定为frame1
    txt(1).visible=true         ''在容器上显示控件
    这是个很好的方法啊
      

  3.   

    现在方法可以不用控件数组来实现动态装载控件
    下面的示例是演示动态加载一个PICTRUE控件,其他的我给出了控件类型,你自己试着做吧,举一反三
    一看类型就明白是什么控件Option Explicit
    Dim oControl As ObjectPrivate Sub Command1_Click()
    Dim oControlType As String
    Dim oControlName As String
    oControlType = "VB.PictureBox"
    'oControlType = "VB.CommandButton"
    'oControlType = "VB.CheckBox"
    'oControlType = "RichText.RichTextCtrl"oControlName = "picLoad"
    Set oControl = Controls.Add(oControlType, oControlName)
    oControl.Width = 400
    oControl.Height = 300
    oControl.Left = 5
    '(ScaleWidth - oControl.Width) / 2
    oControl.Top = 5
    '(ScaleHeight - oControl.Height) / 2
    oControl.Visible = True
    Command2.Enabled = True
    Command1.Enabled = False
    End SubPrivate Sub Command2_Click()
    oControl.Picture = LoadPicture(App.Path & "\1.jpg")
    End SubPrivate Sub Command3_Click()
    End
    End Sub