Forum Discussion

dbattaglia's avatar
dbattaglia
Contributor
9 years ago

Iterate Properties of a VBScript Class Object

I was trying to implement a VBScript class in order to efficiently pass multiple pieces of information across scripts and hit a wall when I found that there is no built in method to iterate over the ...
  • HKosova's avatar
    9 years ago

    Hi dbattaglia,

     

    Thanks for sharing your example! Stack Overflow is a great knowledge base.

     

    By the way, TestComplete has built-in methods aqObject.GetProperties and aqObject.GetFields to iterate over an object's properties. They should work for VBScript classes too. GetProperties returns properties defined as "Property Get/Let/Set Something" and GetFields returns public fields defined as "Public Something".

     

    In your example, you can use:

    Dim props
    Set props = aqObject.GetProperties(genius) While props.HasNext Set prop = props.Next Log.Message prop.Name & ": " & aqConvert.VarToStr(prop.Value) ' & " (" & prop.Category & ")" Wend

    Hope this helps too!