比如说有aaa控件,怎么才能判断aaa控件是否存在属性bbb(不要用on error)。

解决方案 »

  1.   

    我不同意lihonggen0的说法,有些属性是任何浏览器都查不着的,只能凭经验,只要是对的,编译也能过去,最常见的如object属性
      

  2.   

    To Kivic(Kivic):
    这种情况不大可能. 你能举个例子吗 ?
    试想想, 如果有些属性不能通过查询接口查询得到结果, 那它做出来有何用呢.
    可以这样说, 当你建立一个object并且dot了它, 你在快显窗口看到的就应该是它全部的属性和方法.
      

  3.   

    你给我留言,告诉我email地址,我发给你例子我不想在这里公开邮件地址
      

  4.   

    To DeityFox:
      我也想知道怎么枚举一个控件(对象)的属性。
      给你留言了。
      

  5.   

    网上找到的资料
    ======================================================================
    This is how you can get a list of properties for an object or determine if a property exists for an object...
    1) Add the "TypeLib Information" reference to your project.  To do this, click "Project->References..." then select "TypeLib Information" (TLBINF32.DLL) from the reference list.2) Add the following code to a MODULE:'-------------------------------------------------------------------------------
       Public Enum EPType
           ReadableProperties = 2
           WriteableProperties = 4
       End Enum
       Public Function EnumerateProperties(pObject As Object, pType As EPType) As Variant
           Dim rArray() As String
           Dim iVal As Long
           Dim TypeLib As TLI.InterfaceInfo
           Dim Prop As TLI.MemberInfo
           On Error Resume Next
           ReDim rArray(0) As String
           Set TypeLib = TLI.InterfaceInfoFromObject(pObject)
           For Each Prop In TypeLib.Members
               If Prop.InvokeKind = pType Then
                   iVal = UBound(rArray)
                   rArray(iVal) = UCase$(Prop.Name)
                   ReDim Preserve rArray(iVal + 1) As String
               End If
           Next
           ReDim Preserve rArray(UBound(rArray) - 1) As String
           EnumerateProperties = rArray
       End Function
       Public Function DoesPropertyExist(pObject As Object, ByVal _
           PropertyName As String, pType As EPType) As Boolean
           Dim Item As Variant
           PropertyName = UCase$(PropertyName)
           For Each Item In EnumerateProperties(pObject, pType)
               If Item = PropertyName Then
                   DoesPropertyExist = True
                   Exit For
               End If
           Next
       End Function
    '-------------------------------------------------------------------------------
    Then you can do something like this:   If DoesPropertyExist(Command1, "Caption", ReadableProperties) = True Then
           Debug.Print "YES"
       Else
           Debug.Print "NO"
       End IfThe above example will check if the Readable property "Caption" exists for the control "Command1"... In this case it will return true...   If DoesPropertyExist(Command1, "Text", ReadableProperties) = True Then
           Debug.Print "YES"
       Else
           Debug.Print "NO"
       End IfIn the above example we're checking if the "Command1" object contains the readable property "Text".... It does not, so it will return false.Cheers!.)======================================================================
      

  6.   

    Kivic(Kivic) ??那些属性差不到?
    对象浏览器还可以差到隐藏的属性
      

  7.   

    是啊!
    Agree to nik_Amis(Azrael)
    右键单击 Object Browser
    从弹出的快捷菜单里选择 Show Hidden Members
      

  8.   

    有收获, Intelement(智能元素) 从哪里找到的资料,有枚举方法的吗?
      

  9.   

    http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_11167372.htmlSearch Keywords [vb check property exists]