Jump to content
Sign in to follow this  
Killer

Number question

Recommended Posts

Killer

In autoit, if I set a variable to a number example 08, autoit will display the number as only 8. Is there anyway to force it to display the number as it is - 08? :D

Share this post


Link to post
Share on other sites
MFerris

In autoit, if I set a variable to a number example 08, autoit will display the number as only 8. Is there anyway to force it to display the number as it is - 08? :D

You'd have to set it between quotes, forcing into a string format.

$num = "08"

Note that since this is now a string, you would need to convert it back to a number format if you're doing any calculations that rely on it being the number 8. If that's the case, you can switch back by using Int(), ie;

Int($num)

...would return the number 8.

Edited by MFerris

Share this post


Link to post
Share on other sites
SmOke_N

You could use StringFormat also:

$Var2 = 8

$Replace = StringReplace(StringFormat('%2g', $Var2), ' ', 0)

MsgBox(0, 'Test2', $Replace)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Killer

Thanks for the help. I will try to understand the concepts. :D

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.