Micro Focus QTP (UFT) Forums
Getting unexpected result for sum operation - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Getting unexpected result for sum operation (/Thread-Getting-unexpected-result-for-sum-operation)



Getting unexpected result for sum operation - venkatbatchu - 11-04-2009

Hi ALL,
I have been getting some unexpected result with this function which is only getting c=a+b
Code:
Function sum(a,b)
   c=a+b
   msgbox c
End Function
m=datatable.GetRowCount
For i=1 to m step 1
datatable.SetCurrentRow(i)
a=datatable.Value(1,1)
msgbox a
b=datatable.Value(2,1)
msgbox b
Call sum(a,b)
Next
when i perform this function i am geting the results like
ex: a=12 b=5
it is giving the result 125 for c , it has to give 17 (C=A+B)
if c=a-b, a*b then it is giving as expected.
Please let me know whether this is correct one or not....


RE: Getting unexpected result for sum operation - venkatbatchu - 11-04-2009

Code:
Function sum(a,b)
c=a+b
msgbox c
End Function
m=datatable.GetRowCount
For i=1 to m step 1
datatable.SetCurrentRow(i)
a=datatable.Value(1,1)
msgbox a
b=datatable.Value(2,1)
msgbox b
Call sum(a,b)
Next


sorry guys i forgot to use a=cint(a)
b=cint(b)
now it is working as expected...


Thanks all...
Thread is closed..


RE: Getting unexpected result for sum operation - Saket - 11-04-2009

that is what I wanted to suggest you now, meantime you posted.
Its a big issue always with QTP as it does not support data type.

As mentioned by Venkat - thread is closed now.