# Thread: VBscrpt: Addition of 2decimal number(type:strings)

1. ## VBscrpt: Addition of 2decimal number(type:strings)

Dear all,

trimCost=trim(rsTrimDetails.fields(0).value)
paintCost=trim(rsPaintDetails.fields(0).value)
(need to use trim since space it coming after the value)

monthlyCost = paintCost + trimCost

lets say: paintCost =1.8, trimCost = 5.3

I am getting the result as 1.85.3

Kindly let me know how to get the result as 7.1(addition of two)
Thanks,
Shruti

2. ## Re: VBscrpt: Addition of 2decimal number(type:strings)

monthlyCost = CInt(paintCost) + CInt(trimCost )

3. ## Re: VBscrpt: Addition of 2decimal number(type:strings)

cint is actally rounding off the decimal value.

So the result would be
monthlyCost =CInt(1.8) + CInt(5.3)
=2+5
=7

Please suggest some other solution.

Shruti

4. ## Re: VBscrpt: Addition of 2decimal number(type:strings)

Try this

monthlyCost =CDbl(1.8) + CDbl(5.3)

Thanks!

Resolved!

Regards,
Shruti

6. ## Re: VBscrpt: Addition of 2decimal number(type:stri

hey shruti,
Please refer this url
http://www.w3schools.com/vbscript/vb..._functions.asp

and read <u>Math Functions</u>

learning VBscript is very important for QTP otherwise you wont achieves your goals of automation

I hope you got the Idea !

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:56 PM.