Jump to content
Sign in to follow this  
xircon

Resetting data entered into input boxes

Recommended Posts

xircon

I have a large form and need to blank the previously entered data, can I do this in a loop or do I have to hardcode each one as below?

GUICtrlSetData ($Input01, " ")

GUICtrlSetData ($Input02, " ")

GUICtrlSetData ($Input03, " ")

GUICtrlSetData ($Input04, " ")

.....

.....

.....

GUICtrlSetData ($Input20, " ")

cheers

Share this post


Link to post
Share on other sites
smashly

Hi, yep do it in a loop..

#include<GUIConstants.au3>

Global $Input[21], $y = 5

$Gui = GUICreate("Clear Inputs", 210, 540)
For $i = 1 To 20
    $Input[$i] = GUICtrlCreateInput("Input " & $i, 5, $y, 200, 20)
    $y += 25
Next
$Clear = GUICtrlCreateButton("Clear All Inputs", 55, $y, 100, 30)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Clear
            For $c = 1 To 20
                GUICtrlSetData($Input[$c], "")
            Next    
    EndSelect       
WEnd

Cheers

Share this post


Link to post
Share on other sites
xircon

Hi, yep do it in a loop..

#include<GUIConstants.au3>

Global $Input[21], $y = 5

$Gui = GUICreate("Clear Inputs", 210, 540)
For $i = 1 To 20
    $Input[$i] = GUICtrlCreateInput("Input " & $i, 5, $y, 200, 20)
    $y += 25
Next
$Clear = GUICtrlCreateButton("Clear All Inputs", 55, $y, 100, 30)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Clear
            For $c = 1 To 20
                GUICtrlSetData($Input[$c], "")
            Next    
    EndSelect       
WEnd

Cheers

Ah ha! square braces duh!

Share this post


Link to post
Share on other sites
smashly

An array, that's right..lol

If your input boxes are already set to the variable of $InputXX and your script requires to much work to put the inputboxes into an array then you could probably use stringformat and eval to do the same thing in a loop.

Cheers

Edit: Here's the same thing using $inputXX as the variable storing the inputbox control id, and using Eval() and StringFormat() to do the same thing

#include<GUIConstants.au3>

Global $y = 5

$Gui = GUICreate("Clear Inputs", 210, 540)
For $i = 1 To 20
    Assign ("Input" & StringFormat("%02i", $i), GUICtrlCreateInput("Input " & $i, 5, $y, 200, 20), 2)
    $y += 25
Next
$Clear = GUICtrlCreateButton("Clear All Inputs", 55, $y, 100, 30)
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Clear
            For $c = 1 To 20
                GUICtrlSetData(Eval("Input" & StringFormat("%02i", $c)), "")
            Next    
    EndSelect       
WEnd
Edited by smashly

Share this post


Link to post
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
Sign in to follow this  

×