DjDeep00 Posted August 16, 2007 Posted August 16, 2007 I am trying to update the "Start Date" by inputing it into the input field and hitting the change button. But I am not sure what I am doing wrong. Please help... expandcollapse popup#include <GUIConstants.au3> GUICreate("Date Test",300,200) $x=20 $Label_Start_Date = GUICtrlCreateLabel("Start Date", 25, $x, 90, 20, 0x0200 + 0x01) $Start_Date = GUICtrlCreateDate(@MON & "/" & @MDAY & "/" & @YEAR, 115, $x, 100, 20) $x=$x+21 $Label_End_Date = GUICtrlCreateLabel("End Date", 25, $x, 90, 20, 0x0200 + 0x01) $End_Date = GUICtrlCreateDate("", 115, $x, 100, 20) $DTM_SETFORMAT = 0x1032 $style = "MM/dd/yyyy" GUICtrlSendMsg($Start_Date, $DTM_SETFORMAT, 0, $style) GUICtrlSendMsg($End_Date, $DTM_SETFORMAT, 0, $style) $x=$x+41 $New_Date=GUICtrlCreateInput("",25,$x) $x=$x+21 $Change_Button=GUICtrlCreateButton("Change",25,$x) GUISetState() While 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $Change_Button GUICtrlSetData($Start_Date,GUICtrlRead($New_Date)) EndSelect Wend
weaponx Posted August 16, 2007 Posted August 16, 2007 (edited) The date has to be entered in a very specific format. YYYY-MM-DD Single digits must be zero padded. This will get you started: expandcollapse popup#include GUICreate("Date Test",300,200) $x=20 $Label_Start_Date = GUICtrlCreateLabel("Start Date", 25, $x, 90, 20, 0x0200 + 0x01) $Start_Date = GUICtrlCreateDate(@MON & "/" & @MDAY & "/" & @YEAR, 115, $x, 100, 20) $x += 21 $Label_End_Date = GUICtrlCreateLabel("End Date", 25, $x, 90, 20, 0x0200 + 0x01) $End_Date = GUICtrlCreateDate("", 115, $x, 100, 20) $DTM_SETFORMAT = 0x1032 $style = "MM/dd/yyyy" GUICtrlSendMsg($Start_Date, $DTM_SETFORMAT, 0, $style) GUICtrlSendMsg($End_Date, $DTM_SETFORMAT, 0, $style) $x += 41 $New_Date = GUICtrlCreateInput("",25,$x) $x += 21 $Change_Button = GUICtrlCreateButton("Change",25,$x) GUISetState() While 1 Switch GUIGetMsg() case $GUI_EVENT_CLOSE ExitLoop case $Change_Button $A = StringSplit ( GUICtrlRead($New_Date), "/-") $VALIDDATE = StringFormat("%04d",$A[3]) & "-" & StringFormat("%02d",$A[1]) & "-" & StringFormat("%02d",$A[2]) MsgBox(0,"",$VALIDDATE) GUICtrlSetData($Start_Date,$VALIDDATE) EndSwitch Wend This will allow you to enter dates like 8/5/2007 but if you want to use 2-digit year it will take some more work (to determine if it should be 19XX or 20XX) Edited August 16, 2007 by weaponx
martin Posted August 16, 2007 Posted August 16, 2007 (edited) I am trying to update the "Start Date" by inputing it into the input field and hitting the change button. But I am not sure what I am doing wrong. Please help... #include <GUIConstants.au3> GUICreate("Date Test",300,200) $x=20 $Label_Start_Date = GUICtrlCreateLabel("Start Date", 25, $x, 90, 20, 0x0200 + 0x01) $Start_Date = GUICtrlCreateDate(@MON & "/" & @MDAY & "/" & @YEAR, 115, $x, 100, 20) $x=$x+21 $Label_End_Date = GUICtrlCreateLabel("End Date", 25, $x, 90, 20, 0x0200 + 0x01) $End_Date = GUICtrlCreateDate("", 115, $x, 100, 20) $DTM_SETFORMAT = 0x1032 $style = "MM/dd/yyyy" GUICtrlSendMsg($Start_Date, $DTM_SETFORMAT, 0, $style) GUICtrlSendMsg($End_Date, $DTM_SETFORMAT, 0, $style) $x=$x+41 $New_Date=GUICtrlCreateInput("",25,$x) $x=$x+21 $Change_Button=GUICtrlCreateButton("Change",25,$x) GUISetState() While 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $Change_Button GUICtrlSetData($Start_Date,GUICtrlRead($New_Date)) EndSelect Wend You have to use year/month/day regardless of the date format displayed. GuiCtrlSetDat($tart_Date,"2007/08/16") Beaten to it by weaponx, but you are wrong about the slashes weaponx. Edited August 16, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
DjDeep00 Posted August 16, 2007 Author Posted August 16, 2007 You have to use year/month/day regardless of the date format displayed.GuiCtrlSetDat($tart_Date,"2007/08/16")Beaten to it by weaponx, but you are wrong about the slashes weaponx.I knew that, I was just making sure you knew it Martin. Lol...Thanx
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now