Forum Discussion

kikaider69's avatar
kikaider69
Occasional Contributor
12 years ago

How can i convert a string into an actual object

Hi All

  this may have been explained before but i cant find it anywhere. Hoping somebody has a simple solution for me



i have an object



  set HMC_HMQ_link = panel4.textnodeHmcHmqReport



  x = "panel4.textnodeItemPrices"



What i simply want to do is do 'x.click' and that would get me my object click



when i also tried to  use the set command - i got error: object required [string:"panel4.textnodeitemP"]



when that didnt work, i removed the set command  got the following error

when i added the following code to above



  x.Click



the error that then appeared was Object required "x"



Is there a way to convert the string i have defined as 'x' to become an object?



i want to be able to simply add click to whatever value i pass as string and make it work like the first line



steve




3 Replies

  • sastowe's avatar
    sastowe
    Super Contributor
    I may be off base here. My memory is being tickled with CreateObject(sStringwithObjectName). Try that?
  • TonyMro's avatar
    TonyMro
    Occasional Contributor
    In VBScript, your code might look like this:



    Dim oMyObject

    Dim sMyObjectDescriptor



    sMyObjectDescriptor = "panel4.textnodeItemPrices"

    Execute "Set oMyObject= " & sMyObjectDescriptor



    oMyObject.Click
  • aqAnt's avatar
    aqAnt
    SmartBear Alumni (Retired)

    Hello Steven,


    In addition to Tony's answer, you can use the Eval function. For example:



    Set x = Eval("panel4.textnodeItemPrices")

    x.Click