RAMzor Posted December 13, 2007 Share Posted December 13, 2007 I need format variable to dd.ddd format. For example $Var = 2.5, after formating it must be 02.500. I tryed somthing like: $Var = 2.5 $Int =StringFormat( "%00.3f", $Var ) MsgBox(0, "", $Int) But leading zeros not edded, what is wrong? Link to comment Share on other sites More sharing options...
Valuater Posted December 13, 2007 Share Posted December 13, 2007 Here's one....#include <string.au3> $pad = "0" $procrustes = InputBox("How long?","How long do you want your digits?",2) $a = InputBox("Enter a number:","Enter the number you want to convert","1") $pad = _StringRepeat("0",$procrustes - stringlen($a)) $a = StringRight($pad & $a,$procrustes) MsgBox(4096,"",$a)there are more here when i asked a year agohttp://www.autoitscript.com/forum/index.ph...st&p=1121718) Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 13, 2007 Share Posted December 13, 2007 (edited) Hi Val, I guess that is not 100 % correct. He tries to format the string with StringFormat to 02.500 from 2.5 I guess your func doesn't do that. Is it possible to format both sides in one StringFormat? I'll try that So long, Mega Edit: $Var = 2.54 MsgBox(0, "", StringFormat( "%06.3f", $Var)) Edited December 13, 2007 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
RAMzor Posted December 13, 2007 Author Share Posted December 13, 2007 So simple Thanks! Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 13, 2007 Share Posted December 13, 2007 Hi, your welcome. Maybe there should be some more examples for SringFormat in the helpfile. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now