Forum Discussion

mcastellanos's avatar
mcastellanos
Occasional Contributor
9 years ago
Solved

How to use a variable in WinFormsObject() in VBScript?

I want to pass a parameter to below line for "txtPatterName" but TC complete fails to evaluate.

myparam = "txtPatterName"

 

Set Obj = Sys.Process("GemCat_Gui").WinFormsObject("frmPatternMetaData").WinFormsObject("grpPatternID").WinFormsObject("txtPatterName")

 

I am aiming to something like (not sure if concatenation if right):

Set Obj = Sys.Process("GemCat_Gui").WinFormsObject("frmPatternMetaData").WinFormsObject("grpPatternID").WinFormsObject(" & myparam & ")

  • Hi mcastellanos,

     

    You need to change
    WinFormsObject(" & myparam & ")
    to
    WinFormsObject(myparam)

     

    It doesn't need quotes and concatenation because myparam is already a string.

     

    P.S. I moved your question to a separate thread. In the future, please do not reply to old threads with questions that are not related to the original topic. Thanks!

1 Reply

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi mcastellanos,

     

    You need to change
    WinFormsObject(" & myparam & ")
    to
    WinFormsObject(myparam)

     

    It doesn't need quotes and concatenation because myparam is already a string.

     

    P.S. I moved your question to a separate thread. In the future, please do not reply to old threads with questions that are not related to the original topic. Thanks!