Jump to content

Resetting a GUICtrlCreateInput field


Recommended Posts

Hello to all,

I know this must be a simple solution, but I just can't seem to find it. I have a script that asks the user for a date. I then test that date to be certain it's valid. If it's not, I'd like to reset the input field, bring focus back to it and let the user input it again. Here's the script:

$time_cards=GuiCreate("Time Cards", 300, 200,(@DesktopWidth-300)/2, ((@DesktopHeight-200)/2)+10 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetState()
$t_label = GuiCtrlCreateLabel("TIME CARDS UPDATED THROUGH: ", 10, 40, 190, 20, $SS_CENTER)
$t_input_udate = GuiCtrlCreateInput("", 50, 70, 45, 20, $ES_NUMBER)
GUICtrlSetLimit($t_input_udate,6)
GuiCtrlSetState($t_input_udate, $GUI_FOCUS);start with cursor in this textbox
$t_submit_button = GuiCtrlCreateButton("SUBMIT", 70, 150, 60, 25, $BS_CENTER)
    GuiCtrlSetState($t_submit_button, $GUI_DEFBUTTON)
$t_cancel_button = GuiCtrlCreateButton("CANCEL", 160, 150, 60, 25, $BS_CENTER)

while 1
    $t_msg = GuiGetMsg()
    Select
        case $t_msg=$GUI_EVENT_CLOSE or $t_msg=$t_cancel_button
            Exit
    case $t_msg=$t_submit_button
            $t_udate=GUICtrlRead($t_input_udate)
            $t_udate=StringMid($t_udate,1,2)&"/"&StringMid($t_udate,3,2)&"/"&StringMid($t_udate,5,2)
            $t_val_udate="20"&StringMid($t_udate,7,2)&"/"&StringMid($t_udate,1,3)&StringMid($t_udate,4,2)
            if _DateIsValid($t_val_udate)=0 then
                GuiCtrlSetState($t_input_udate, $GUI_FOCUS)
                ContinueLoop
            endif
            ExitLoop
    EndSelect
WEnd

Advice would be greatly appreciated.

David

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...