If txtName.Parent Is Me Then ....

解决方案 »

  1.   


    Dim ctl As ControlFor Each ctl In form1.Controls
        If ctl.Name = "txtname" Then
        Else
        End If
    Next
      

  2.   

    Private Function IsExist(ByVal ControlName As String) As Boolean
        Dim ctlOne As Control
        
        IsExist = False
        For Each ctlOne In Form1.Controls
            If UCase(ctlOne.Name) = UCase(ControlName) Then
                IsExist = True
                Exit For
            End If
        Next
    End Function
      

  3.   

    Private Function IsExist(ByVal Control As String) As Boolean
        Dim ctl As Control
        
        IsExist = False
        For Each ctl In Me.Controls
            If ctl.Name) = Control Then
                IsExist = True
                Exit For
            End If
        Next
    End Function
      

  4.   

    agree with  fuxc(Michael)