Forum Discussion

ChrisMac's avatar
ChrisMac
Contributor
15 years ago

can't pass in a variable to aqObject.CheckProperty

Hi all -

I'm trying to pass in a variable to aqObject.CheckProperty but keep getting a vbscript runtime error.An example:



Sub Marine()

Dim rownum

rownum=14

   Set Grid = <object name>    

   Call aqObject.CheckProperty(Grid, "wValue(rownum, ""Mat-Result"")", 0, 30)

End Sub 



If I hardwire an integer it works fine but when I try to set rownum = 15 and use rownum instead of 15 I get:



Access violation at address 16EEE6FF in module 'tcCoreEx.dll'. Read of address 00000000

Error location:

Unit: "Intellibid\Special Items\Script\junk"

Line: 14 Column: 3.



They're both integers, I've used VarType  and it came back 2 which is an integer. Any ideas?



Chris

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Try the following:



    Sub Marine()

    Dim rownum

    rownum=14

       Set Grid = <object name>    

       Call aqObject.CheckProperty(Grid, "wValue(" & VarToStr(rownum) & ", ""Mat-Result"")", 0, 30)

    End Sub  




    Because rownum is a variable, you need to concatenate it into the string that is being used as the property check.  


  • Thanks Robert! That does work. For the record, it works without the VarToStr.



    Chris
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Glad to hear!



    I usually like to drop in those explicit conversion calls.  TestComplete does implicitly cast things (rownum is an integer being used as a string) but I've hard trouble in the past where something that I thought was going to be used as a string ended up giving a "type mismatch" so I always explicitly cast now... saves trouble in the long run. :-)