GuiControlGet 4-digits number convert to MMMdd%A_YYYY% Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

21 Sep 2017, 22:39

Allow me to ask a basic question, MyEdit is an EditBox, which i type 4-digits number, for example: 0901, then GuiControl,, Date1, (;the new FormatTime), with the below codes, the result will be current date (SEP. 22, 2017), but not the one it should be (SEP. 01, 2017), what's going on???

Code: Select all

M1:
GuiControlGet, Date,, MyEdit
if (StrLen(Date) != 4)
	return

FormatTime, Date2, Date, MMM.%A_Space%dd,%A_Space%%A_YYYY%
StringUpper, Date2, Date2
GuiControl,, Date1, %Date2%
return
Attachments
20170922114030.png
20170922114030.png (1.2 KiB) Viewed 1383 times
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

21 Sep 2017, 23:37

If blank or omitted, it defaults to the current time. Otherwise, specify the time to use for the operation ...
Let's guess the format you've handed over isn't valid. So the output will be the default AKA the current date.

Code: Select all

M1:
Gui, Submit, NoHide
FormatTime, Date2,% yyyy . Date . "000000", MMM. dd, yyyy
MsgBox % Date2
Return
Not tested.
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

22 Sep 2017, 01:06

Code: Select all

M1:
GuiControlGet, Date,, MyEdit
if (StrLen(Date) != 4)
	return
MsgBox % Date ;while type 0901 in Editbox "MyEdit", msgbox prompt "0901"
FormatTime, Date2,% yyyy . Date . "000000", MMM. dd, yyyy 
StringUpper, Date2, Date2
MsgBox % Date2 ;msgbox prompt empty
GuiControl,, Date1, %Date2%
return
<It's not working!> :|
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

22 Sep 2017, 02:01

ivill wrote:

Code: Select all

M1:
GuiControlGet, Date,, MyEdit
if (StrLen(Date) != 4)
	return
MsgBox % Date ;while type 0901 in Editbox "MyEdit", msgbox prompt "0901"
FormatTime, Date2,% yyyy . Date . "000000", MMM. dd, yyyy 
StringUpper, Date2, Date2
MsgBox % Date2 ;msgbox prompt empty
GuiControl,, Date1, %Date2%
return
<It's not working!> :|
FormatTime, Date2,% yyyy . Date . "000000", MMM. dd, yyyy ; wrong
GOSH, it wasn't necessary to "force" an expression using % as FormatTime already expects an input that way. So simply remove it ... :shh:
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

22 Sep 2017, 02:32

@BoBo somehow it still... not working, could you have a try on the test script:

Code: Select all

Gui, Add, Text, x10 y25, Date:
Gui, Add, Edit, x85 y25 W70 h20 number vMyEdit gM1
Gui, Add, Text, x10 y50, D:
Gui, Add, Edit, x85 y50 w352 h20 ReadOnly vDate1

Gui, Show,,
Return

M1:
Gui, Submit, NoHide
GuiControlGet, Date,, MyEdit
if (StrLen(Date) != 4)
	return
FormatTime, Date2, yyyy . Date . "000000", MMM. dd, yyyy
StringUpper, Date2, Date2
MsgBox % Date2
GuiControl,, Date1, %Date2%
return
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%  Topic is solved

22 Sep 2017, 02:58

ivill wrote:
BoBo wrote:@BoBo somehow it still... not working, could you have a try on the test script:

[...]

Code: Select all

#SingleInstance, Force

Gui, Add, Text, x10 y25										, Date:
Gui, Add, Edit, x85 y25 w70		h20	number		vDate gM1	, 090
Gui, Add, Text, x10 y50										, D:
Gui, Add, Edit, x85 y50 w352	h20 ReadOnly	vDate1 

Gui, Show,,`t
Return

M1:
Gui, Submit, NoHide
If (StrLen(Date) != 4)
	Return
FormatTime, Date2,% A_YYYY . Date , MMM. dd, yyyy
StringUpper, Date2, Date2
GuiControl,, Date1,% Date2
Return

F10::Reload
Tested.
User avatar
ivill
Posts: 124
Joined: 13 May 2016, 02:23

Re: GuiControlGet 4-digits number convert to MMMdd%A_YYYY%

22 Sep 2017, 04:25

BoBo wrote:
ivill wrote:
BoBo wrote:@BoBo somehow it still... not working, could you have a try on the test script:

[...]

Code: Select all

#SingleInstance, Force

Gui, Add, Text, x10 y25										, Date:
Gui, Add, Edit, x85 y25 w70		h20	number		vDate gM1	, 090
Gui, Add, Text, x10 y50										, D:
Gui, Add, Edit, x85 y50 w352	h20 ReadOnly	vDate1 

Gui, Show,,`t
Return

M1:
Gui, Submit, NoHide
If (StrLen(Date) != 4)
	Return
FormatTime, Date2,% A_YYYY . Date , MMM. dd, yyyy
StringUpper, Date2, Date2
GuiControl,, Date1,% Date2
Return

F10::Reload
Tested.
Fantastic! thank you, anyway, Congrats on your level up to be the mod of "Ask for help" :thumbup: :thumbup: :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Draken, Google [Bot], Spawnova and 118 guests