Sign in to follow this  
Followers 0
Killer

Number question

4 posts in this topic

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



#2 ·  Posted (edited)

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

You could use StringFormat also:

$Var2 = 8

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

MsgBox(0, 'Test2', $Replace)


[center]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.[/center]

Share this post


Link to post
Share on other sites

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  
Followers 0