Jump to content

StringFormat


RAMzor
 Share

Recommended Posts

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

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 ago

http://www.autoitscript.com/forum/index.ph...st&p=112171

8)

NEWHeader1.png

Link to comment
Share on other sites

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

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

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