VB Control 类型

Eddy 发布于2009-12-1 11:3:11 分类: 程序设计 已浏览loading 网友评论0条 我要评论

在 Visual Basic 6.0 中,Controls 集合是表示窗体或容器控件上的控件的元素的集合。

Add 方法
在 Visual Basic 6.0 中,Controls 集合的 Add 方法是后期绑定的;通过将 Control 类指定为参数,在 Add 方法中创建控件。

Remove 方法
Visual Basic 6.0 Controls 集合的 Remove 方法只能用于使用 Add 方法添加的控件

计时器和菜单控件
在 Visual Basic 6.0 中,Timer 和 Menu 控件是 Controls 集合的成员。

包含的控件
Visual Basic 6.0 Controls 集合包括作为容器控件的子控件的控件(如位于 Frame 控件上的控件)。

' Visual Basic 6.0
Private Sub Command1_Click()
    ' Declare a new Control variable.
    Dim c As Control
    ' Create and add the new control.
    Set c = Controls.Add("VB.TextBox", "Text1")
    ' Make the new control visible.
    c.Visible = True
    ' Set the initial text.
    c.Text = "Hello"
    ' Retrieve the text from the new TextBox.
    If Controls.Count > 1 Then
        MsgBox (Controls("Text1").Text)
    End If
    ' Remove the new control.
    Controls.Remove (Text1)
    ' The following line causes a compilation error.
    ' You cannot remove controls added at design time.
    Controls.Remove (Command1)
End Sub

已经有(0)位网友发表了评论,你也评一评吧!
原创文章如转载,请注明:转载自Eddy Blog
原文地址:http://www.rrgod.com/program/174.html     欢迎订阅Eddy Blog

记住我的信息,下次不用再输入 欢迎给Eddy Blog留言