Forum Discussion

par_away's avatar
par_away
Occasional Contributor
10 years ago

Getting a Type Mismatch error when using a Project Suite variable as input for SetText operation

So I have 2 keyword tests (KT1 and KT2) and a project suite variable (Var1), using the Set Variable Value operation, I assigned the value of Var1 with type Object. This variable gets the Text property of the object. Now I need this Var1 as an input value for KW2 but I get a Type Mismatch error when using Var1 as value to a SetText operation. I also tried using Keys to no avail. Is there something I need to do first to be able to enter Var1's value in KW2?

  • You've set the variable to a type of object.

     

    But you only want the text property of an object stored in it.

     

    Thats a string. So you need to set the variable type to string as you're using it store a property of an object (a string in this case), not the object itself. A string should be usable for text entry elsewhere without any problems.

     

    (And I would recommend using "Keys" rather than "SetText" as it's what the user would do when entering text. SetText applies it directly to the control and may not activate any event triggers attached to the field or be retained when you exit the field.)

  • You've set the variable to a type of object.

     

    But you only want the text property of an object stored in it.

     

    Thats a string. So you need to set the variable type to string as you're using it store a property of an object (a string in this case), not the object itself. A string should be usable for text entry elsewhere without any problems.

     

    (And I would recommend using "Keys" rather than "SetText" as it's what the user would do when entering text. SetText applies it directly to the control and may not activate any event triggers attached to the field or be retained when you exit the field.)