Jump to content

Can AutoIt Turn A Decimal Into A Percent?


Recommended Posts

I Was Wondering Could AutoIt Do This...

Decimal = 0.5, Percent = 50%

Decimal = 0.2, Percent = 20%

Decimal = 0.661, Percent = 66.1%

What I'm Asking Is Could You Write A Function To Go 2 Places To The Right Of The Decimal And Return The Percent..

I Can't Get The Correct Wording.. I Hope Some 1 Can Help Me ;)

- John

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

or you can try this :

$n = 0.661321
MsgBox(0,"Test",DecToPercent($n,2))

Func DecToPercent($n_DecValue,$i_OptionalDecimal=2)
    Return StringFormat("%." & $i_OptionalDecimal & "f %%", $n*100) 
EndFunc
Interesting script.

The variable,$n, was not declared a Global variable, yet, it is acting like one.

How 'bout that.

Nice optional parameter, I would not have thought of that.

Link to comment
Share on other sites

Interesting script.

The variable,$n, was not declared a Global variable, yet, it is acting like one.

How 'bout that.

Nice optional parameter, I would not have thought of that.

oups I should $n_DecValue instead of $n in my function....

Func DecToPercent($n_DecValue,$i_OptionalDecimal=2)

Return StringFormat("%." & $i_OptionalDecimal & "f %%", $n_DecValue*100)

EndFunc

Edited by baghenamoth
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...