Sign in to follow this  
Followers 0
silvano

number format

6 posts in this topic

hi,

sorry, i have search in the forum but i don't know the correct terms to search for my problem...

i have one dynamic number like this: 1200.3448952

i would to change them in:

1.200,34

i have write this func:

Func decimale($campo,$scrivi=0)
$decimale_pulito = StringFormat("%.2f%",$campo)
If $scrivi = 1 Then
$decimale_pulito = StringStripWS(StringReplace($decimale_pulito,".",","),8)
EndIf
Return $decimale_pulito
EndFunc

MsgBox(0,"",decimale("1200.3448952",1))

but this return only: 1200,34

can i format the numbers:

12000.35698 or 158000.3569

like: 12.000,36 and 158.000,36

thanks

Share this post


Link to post
Share on other sites



hi,

sorry, i have search in the forum but i don't know the correct terms to search for my problem...

i have one dynamic number like this: 1200.3448952

i would to change them in:

1.200,34

i have write this func:

Func decimale($campo,$scrivi=0)
$decimale_pulito = StringFormat("%.2f%",$campo)
If $scrivi = 1 Then
$decimale_pulito = StringStripWS(StringReplace($decimale_pulito,".",","),8)
EndIf
Return $decimale_pulito
EndFunc

MsgBox(0,"",decimale("1200.3448952",1))oÝ÷ Ù»­¶¬­ën®z'-vÓMøq©â~æjÛaz{¦mêì×m4Ó~z÷Ê+×4ÓMùëÙbívÓM7é©Ý×4ÓMú¶§Ïêº^²¶§X¤zØb±«­¢+Ø¥¹±Õ±ÐíMÑÉ¥¹¹ÔÌÐì(ÀÌØíÍÑÉ¥¹ôÅÕ½ÐìÄÈÀÀ¸ÌÐÐàäÔÈÅÕ½Ðì(ÀÌØíÍÑÉ¥¹|ÄôMÑÉ¥¹MÁ±¥Ð ÀÌØíÍÑÉ¥¹°ÅÕ½Ðì¸ÅÕ½Ðì¤(ÀÌØíMÑÉ¥¹|Èô}MÑÉ¥¹
½µµ ÀÌØíÍÑÉ¥¹|ÅlÅt¤(ÀÌØíÍÑÉ¥¹|ÌôMÑÉ¥¹IÁ± ÀÌØíMÑÉ¥¹|È°ÅÕ½Ðì°ÅÕ½Ðì°ÅÕ½Ðì¸ÅÕ½Ðì¤(ÀÌØíÍÑÉ¥¹|ÐôÀÌØíÍÑÉ¥¹|̵ÀìÅÕ½Ðì°ÅÕ½ÐìµÀíMÑÉ¥¹1Ð ÀÌØíÍÑÉ¥¹|ÅlÉt°È¤)5Í  ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍÑÉ¥¹|Ф

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Yes!! :)

thank yuo very much!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes!! ;)

thank yuo very much!

if the number is more then 0.11 like 0.1100000000000000000000000000000000000001 to set ti to 0.12

i hope that this is working :)

#include <String.au3>
$string = "1200.9800001"
$string_1 = StringSplit($string, ".")
$string_4 = $string_1[2]
$string_4_1 = StringLeft($string_1[2],2)
$string_4_2 = StringLeft($string_1[2],2)
$string_6 = StringLen($string_4)
$string_6 = $string_6-2
for $x = 1 to $string_6
    $string_4_1 = $string_4_1&"0"
Next
Select
    case $string_4_1 < $string_1[2]
    Select
        Case $string_4_2 <> "99"
            $string_7 = $string_4_2+1
        Case $string_4_2 = "99"
            $string_7 = "00"
            $string_1[1] = $string_1[1]+1
    endselect
    case $string_4_1 >= $string_1[2]
        $string_7 = $string_4_2
endselect
$String_2 = _StringAddComma($string_1[1])
$string_3 = StringReplace($String_2,",",".")
$string_8 = $string_3&","&$string_7
MsgBox(0,"",$string_8)

i forgot to add if 99

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

i have play this:

#include<string.au3>
$string = "1000.00"

Func decimaleVideo1($string)
$decimale_pulito = StringFormat("%.2f%",$string)
$a = _StringAddComma ( $decimale_pulito,".")
$b = StringReplace($a,stringRight($a,3),","&stringRight($a,2))
return $b
EndFunc
MsgBox(0,"", decimaleVideo1($string))

and work, but if the number is 1000.00 return 1,000,00 and if the number is 1100.00 return correctly 1.100,00

why!?

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