Forum Discussion

idaj's avatar
idaj
New Contributor
4 years ago

FieldByName returns integer instead of money

Hello,

I need to get cell's value from a table. I use the following line:
Qry.FieldByName(paramName).Value;

 

The problem is the value is "223,00" or similar, but I always get "223".

Everything works fine if the value is integer.

 

(Qry.FieldByName(paramName).AsFloat does not work)

  • Lee_M's avatar
    Lee_M
    Community Hero

    Your issue here is that no matter what you type you set the variable to (if using KW) TC will ALWAYS read values as a string

     

    you can try using aqConvert to cast your string to a float

     

    https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/strtofloat.html

     

    let amount = Qry.FieldByName(paramName).Value;

    Log.Message(aqConvert.StrToFloat(amount));

     

    or

     

    Log.Message(aqConvert.StrToFloat("Qry.FieldByName(paramName).Value"));

     

     

     

     

     

     

    • idaj's avatar
      idaj
      New Contributor

      Unfortunately, none of above works. I still get values as "235" instead "235,00" etc.

      I don't think that the problem is TC reading values as strings. I think that function "FieldByName" is a problem but I have no idea how to replace it.

      • Lee_M's avatar
        Lee_M
        Community Hero

        Try using the Object spy on the field, you should be able to see what properties are in the field

         

        maybe 

        - contentText

        - wtext

         

        may be better suited ?