Help with Format() Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
djuga
Posts: 8
Joined: 28 Jul 2019, 08:16

Help with Format()

30 May 2020, 00:02

Need format euro currency to human readable

Code: Select all

Value := Format("{:#.0f}", 350)
Msgbox %Value% ; Will give "350." but need "3.50"
User avatar
Smile_
Posts: 215
Joined: 03 May 2020, 00:51

Re: Help with Format()

30 May 2020, 00:19

Might this helps

Code: Select all

int := 350 // 100
dec := mod(350,100)
Value := int "." dec
Msgbox %Value% ; Will give "3.50"
Edit:
Or like this

Code: Select all

preValue := Format("{:.2e}", 350)
Value := Format("{:.4s}", preValue)
Msgbox %Value% ; Will give "3.50"
djuga
Posts: 8
Joined: 28 Jul 2019, 08:16

Re: Help with Format()

30 May 2020, 00:48

Smile_ wrote:
30 May 2020, 00:19
Might this helps

Code: Select all

int := 350 // 100
dec := mod(350,100)
Value := int "." dec
Msgbox %Value% ; Will give "3.50"
Edit:
Or like this

Code: Select all

preValue := Format("{:.2e}", 350)
Value := Format("{:.4s}", preValue)
Msgbox %Value% ; Will give "3.50"
It works, but it's a bad way
Format is called 2 times
teadrinker
Posts: 1628
Joined: 29 Mar 2015, 09:41
Contact:

Re: Help with Format()  Topic is solved

30 May 2020, 01:08

Maybe like this:

Code: Select all

MsgBox, % Round(350/100, 2)
garry
Posts: 2272
Joined: 22 Dec 2013, 12:50

Re: Help with Format()

30 May 2020, 07:14

example round 0 / 5 cents

Code: Select all

;- round 0/5 
setformat,float,0.2
d1:=4.92   ;- 4.90
d2:=4.93   ;- 4.95
d3:=4.97   ;- 4.95
d4:=4.98   ;- 5.00
;----------
d1:=(round(d1*20)/20)
d2:=(round(d2*20)/20)
d3:=(round(d3*20)/20)
d4:=(round(d4*20)/20)
msgbox,%d1%`n%d2%`n%d3%`n%d4%
exitapp

Return to “Ask For Help”

Who is online

Users browsing this forum: afe, AHKStudent, Bing [Bot], c7aesa7r, Green and 166 guests