Micro Focus QTP (UFT) Forums
How can I crop a very large number? - 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: How can I crop a very large number? (/Thread-How-can-I-crop-a-very-large-number)



How can I crop a very large number? - coolbeans12351 - 11-19-2010

I'm kind of a newbie with QTP; can do most basic stuff. I have a very large number I need to crop, and cannot find anything in the books I have about cropping the number. The number is $2,459.000.168, and I just need it to be $2,459.00

Any help would be greatly appreciated!

Thx!


RE: How can I crop a very large number? - nandu - 11-19-2010

Hi..

You can use Round() to get u r required Result..

Ex :
val = 2,459.000.168
val = Round(2,459.000.168, 2) -- now val contains 2,459.00
val = Round(2,459.000.168, 3) -- now val contains 2,459.000

Thx..


RE: How can I crop a very large number? - KavitaPriyaCR - 11-19-2010

Hi
val = 2459000.16866
val = Round(2459000.16866, 2) -- now val contains 2,459,000.17
val = Round(2459000.16866, 3) -- now val contains 2,459,000.168
ALSO
val = 2459000.16866
val = FormatNumber(2459000.16866, 2) '-- now val contains 2,459,000.17
val = FormatNumber(2459000.16866, 3) '-- now val contains 2,459,000.168
will give same result

Nandu, Round(2,459.000.168, 2) -> You can't pass arguments like this, will get error i guess.


RE: How can I crop a very large number? - coolbeans12351 - 11-19-2010

Thank you so much for your reply! I figured out why I got such a strange number. I extracted it from a web table with multiple columns. The first column contained the cost $2,459.00; the second column contained a rate of 0.168

Any way I can extract only the number from the first column? Here's what I used to extract:
Code:
string1=Instr(1,prem1,"Minimum Premium",1)
string2=Mid(prem1,string1)
string3=Replace(string2,"Minimum"," ",1)
str_1=Instr(2,Trim(string3),"$",1)
CroppedPrem=Trim(Left(string3,str_1))


Again, I so appreciate your reply!