vb 判断 控件是否存在

引用:http://zhidao.baidu.com/question/95306345.html

Private Sub Form_load()
    Dim i As Integer
    For i = 0 To Me.Controls.Count - 1
        If Me.Controls.Item(i).Name = "Shape1" Then 'me 可以用你控件的窗体名称替换。
            MsgBox "存在"
            Exit Sub
        End If
    Next
    If i > Me.Controls.Count - 1 Then
        MsgBox "不存在"
    End If
End Sub
posted @ 2011-11-11 14:38  镇水古月  阅读(1009)  评论(0)    收藏  举报