Jump to content

Number question


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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.

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...