führende Nullen Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

effel
Posts: 550
Joined: 16 Jan 2018, 13:34

führende Nullen

18 Jan 2024, 02:07

Hallo, wie bekomme ich führende Nullen vor thisDay bzw. thisMonth.

Ich möchte 01.. 02 statt 1.. 2

Ich habe es leider in der Hilfe auf github nicht verstanden.

Danke fürs lesen

Code: Select all

	for thisMonth, month in x := strSplit("31,29,31,30,31,30,31,31,30,31,30,31",",") {  ; if isLeapYear 
		loop,% month 
		{
		thisDay++
		gosub start
		}
		thisDay:=0
	} 

	start:
;	SetFormat, Float, 0.1
	tooltip % thisDay a_tab thisMonth a_tab x.length()
	sleep, 100
	return
just me
Posts: 9542
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: führende Nullen  Topic is solved

18 Jan 2024, 04:04

Moin,

Code: Select all

	tooltip % Format("{:02}", thisDay) a_tab Format("{:02}", thisMonth) a_tab x.length()
{:02} für 2 Stellen, {:03} für 3 Stellen, ...
Größere Werte werden nicht verändert.

Alternative:

Code: Select all

	tooltip % Format("{:02}`t{:02}`t{}", thisDay, thisMonth, x.length())
just me
Posts: 9542
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: führende Nullen

18 Jan 2024, 04:09

Noch eine 'klassische' Option:

Code: Select all

thisDay := 1
MsgBox, % SubStr("0" thisDay, -2)
Wenn thisDay mehr als 2 Stellen hat, wird aber abgeschnitten.
effel
Posts: 550
Joined: 16 Jan 2018, 13:34

Re: führende Nullen

18 Jan 2024, 13:17

just me wrote:
18 Jan 2024, 04:04
vielen Dank @just me

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 11 guests