Jump to content
Sign in to follow this  
Awais

How to set Date back to datepic

Recommended Posts

Awais

i want to set date back but it save date for any record like 12 and when i want to set date back to date pic by click 2nd button but it does not set it what is the problem please help ?

#RequireAdmin
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("TEMP", 615, 437, 201, 145)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
Global $Date1 = GUICtrlCreateDate("2014/08/19 11:24:56", 152, 112, 186, 21)
Global $Input1 = GUICtrlCreateInput("", 152, 56, 121, 21)
Global $Button1 = GUICtrlCreateButton("SAVE", 152, 152, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
Global $Button1 = GUICtrlCreateButton("SET BACK", 152, 200, 75, 25)
GUICtrlSetOnEvent($Button1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    Local $ID = GUICtrlRead($Input1)
    Local $date = GUICtrlRead($Date1)
    IniWrite("C:\TEMP.INI",$ID,"Date",$date)
EndFunc
Func Button2Click()
    Local $ID = GUICtrlRead($Input1)
    Local $date = IniRead("C:\TEMP.INI",$ID,"Date","No Date")
    GUICtrlSetData($Date1,$date)
EndFunc
Func Form1Close()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
Zedna

Implicitly in INI file is date stored in long date format, in my (Czech) case it's 19. srpna 2014

You have to change date format to DTS_SHORTDATEFORMAT (yyyy/mm/dd) and save/load date in this format

#RequireAdmin
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("TEMP", 615, 437, 201, 145)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
Global $Date1 = GUICtrlCreateDate("2014/08/15", 152, 112, 186, 21, $DTS_SHORTDATEFORMAT)
Global $Input1 = GUICtrlCreateInput("", 152, 56, 121, 21)
Global $Button1 = GUICtrlCreateButton("SAVE", 152, 152, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
Global $Button1 = GUICtrlCreateButton("SET BACK", 152, 200, 75, 25)
GUICtrlSetOnEvent($Button1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    Local $ID = GUICtrlRead($Input1)
    Local $date = GUICtrlRead($Date1)
    IniWrite("C:\TEMP.INI",$ID,"Date",$date)
EndFunc
Func Button2Click()
    Local $ID = GUICtrlRead($Input1)
    Local $date = IniRead("C:\TEMP.INI",$ID,"Date","No Date")
    $date = StringSplit($date, '.')
    If StringLen($date[1]) = 1 Then $date[1] = '0' & $date[1]
    If StringLen($date[2]) = 1 Then $date[2] = '0' & $date[2]
    $date = $date[3] & '/' & $date[2] & '/' & $date[1] ; d.m.yyyy --> yyyy/mm/dd
    GUICtrlSetData($Date1,$date)
EndFunc
Func Form1Close()
    Exit
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites
Awais

(34) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$date = $date[3] & '/' & $date[2] & '/' & $date[1]
$date = ^ ERROR

Share this post


Link to post
Share on other sites
Awais

i have second problem 

i just want to set a specific date but it sets the date but incorrect 

i want to set date 2000/01/1 

but it set it to 2000/01/19 

what is the error ?

#RequireAdmin
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("TEMP", 615, 437, 201, 145)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
Global $Date1 = GUICtrlCreateDate("2014/08/19 12:47:43", 104, 80, 186, 21, 0)
Global $Input1 = GUICtrlCreateInput("", 152, 56, 121, 21)
Global $Button1 = GUICtrlCreateButton("SAVE", 152, 152, 75, 25)
GUICtrlSetOnEvent($Button1, "Button1Click")
Global $Button1 = GUICtrlCreateButton("SET BACK", 152, 200, 75, 25)
GUICtrlSetOnEvent($Button1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
EndFunc
Func Button2Click()
    GUICtrlSetData($Date1,"2000/01/1")
EndFunc
Func Form1Close()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×