如题:
控件数组在窗体设计的时候已经创建好了。 text1(5)
然后后面动态添加的控件,都为控件数组的text1(5)里的,试了半天还是不会,请教。
Private Sub Command6_Click()ReDim Preserve Text1(Text1.Count + 1)
Set newtxt = Controls.Add("VB.TextBox", "Text1", Frame1)
With newtxt
.Visible = True
.Enabled = True
End With
MsgBox newtxt.Name
'Set 其他控件 = Controls.Add("VB.TextBox", newtxt)
End Sub

解决方案 »

  1.   

    Private Sub Command6_Click()
        Dim i As Integer
        
        i = Text1.UBound + 1
        Load Text1(i)
        
        With Text1(i)
            .Visible = True
            .Enabled = True
            .Left = Text1(i - 1).Left
            .Top = Text1(i - 1).Top + 500
        End With
        
        MsgBox Text1(i).Name
    End Sub
      

  2.   

    Load text1(i)就可以, 只要该序号的控件元素未被加载即可.
      

  3.   


    老马多了个奖章,,,MVP