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
原文地址:https://www.cnblogs.com/sode/p/2245678.html