Forum Discussion

kandy1984's avatar
kandy1984
Contributor
6 years ago
Solved

Using data from excel sheet for FindChild and passing as regex

Hi Everyone,

 

Thanks for helping. I am using a findChild method and passing in the properties from excelsheet.

 

Set Loading= Aliases.DataAcquisition........

           PropArray = Array("UITracingText")
           ValuesArray = Array("*Loader 01*") ----> This value would need to come from an excel sheet Driver.Value(1)) but needs to be able to match part only Loader 01 as UITracingText is a long string.

Set Loading = Loading.FindChild(PropArray, ValuesArray, 10000)

 

 ValuesArray = Array("*Loader 01*") ----> This value would need to come from an excel sheet Driver.Value(1)) but needs to be able to match part only Loader 01 as UITracingText is a long string. If i dont use the value from exel sheet, then i can simple make it  ValuesArray = Array("*Loader 01*") but i only want string which are matching.

 

Thanks for helping.

 

Sudha

  • Simply concatentate the string...

     

     

    ValuesArray = Array("*" & Driver.Value(1) & "*")

     

    This will put the value from that column in the array appropriately.

     

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Simply concatentate the string...

     

     

    ValuesArray = Array("*" & Driver.Value(1) & "*")

     

    This will put the value from that column in the array appropriately.

     

  • IStaroverov's avatar
    IStaroverov
    SmartBear Alumni (Retired)

    Hi
    If I understood correctly, need to get "Loader 01" text from a long string and paste to the "FindChild" method
    You can try this code:
    ...
    Dim regEx, Matches, value
    Set regEx = New RegExp
    regEx.Pattern = "Loader \d\d"
    Set Matches = regEx.Execute(Driver.Value(1))
    if (Matches.Count <> 0) then value = Matches.Item(0).Value
    Set Loading = Loading.FindChild("UITracingText", "*" + value + "*", ...)
    ...