Passing Long Integers from datatable using CDbl
You might have wanted to pass long integers like from 10 - 13 digits and every time you execute your code, QTP datatable changes your integer value into some scientific value containing plus(+) and decimal signs. Changing the column 'Format' does not seems to be beneficial. (At least not for me).
For example if you have tried automating a payment form that takes in credit card number and other details, you might have came across this problem.
So here i will be telling you about some very useful build-in functions that can help in this error. Executing the code below will give you an error of invalid input as the value in your datatable will be something like 1.111111111E+111.
For example if you have tried automating a payment form that takes in credit card number and other details, you might have came across this problem.
So here i will be telling you about some very useful build-in functions that can help in this error. Executing the code below will give you an error of invalid input as the value in your datatable will be something like 1.111111111E+111.
Browser("name:=.*").Page("title:=.*").WebEdit("html id:=some id").Set DataTable("CardNumber",dtGlobalSheet)
Changing column format to Fixed, Custom or any other will give you following error 'The parameter is incorrect'
So let us play with some variables and built-in functions.
myCardNo = DataTable.GetSheet("sheetname").GetParameter("CardNo")
resultedCardNo = CDbl(myCardNo)
Browser("name:=.*").Page("title:=.*").WebEdit("html id:=some id").Set resultedCardNo
In line # 3 we have used CDbl which converts your integer to Double. So when we execute the above code, the 13 digit value in datatable will be converted into a double datatype and you can easily set your textbox value. [For further details on Cdbl, Check in Quick test professional Help.]
Hope this article will be help you in dealing with long numerics. Happy scripting.
Hope this article will be help you in dealing with long numerics. Happy scripting.
Comments
Post a Comment