Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting unexpected result for sum operation
#1
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....
#2
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..
#3
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.



Possibly Related Threads…
Thread Author Replies Views Last Post
  Web Testing and Unexpected Server Errors zunebuggy 0 1,590 01-24-2018, 11:41 PM
Last Post: zunebuggy
  The DataTable.ExportSheet operation failed. Invalid file. Niraj 2 6,976 05-05-2015, 11:40 PM
Last Post: babu123
  Excel operation - to find usedrange of rows & col pooja 1 10,375 02-19-2015, 04:06 AM
Last Post: supputuri
  Capturing the exact time when an operation is performed. Dilliz 2 3,749 01-09-2014, 03:30 PM
Last Post: Dilliz
  How to capture operation such as hovering a mouse nikhilcogni 5 5,559 03-23-2013, 11:17 AM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)