Jump to content

Clear lots of in puts/combo's at the same time


Rex
 Share

Recommended Posts

Hi there

I have a lot of inputs that i would like to clear and lots of combo's that i would like to reset to default.

All are formated like this

$Tab_Fx_Customer_Inputy = GUICtrlCreateInput("", 244, 42, 65, 21)
$Tab_Fx_CollieCount_Inputy = GUICtrlCreateInput("", 316, 42, 57, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
$Tab_Fx_CollieType_Comboy = GUICtrlCreateCombo("PLL", 380, 42, 49, 25)
GUICtrlSetData($Tab_Fx_CollieType_Comboy, "CLL")
$Tab_Fx_CollieWeight_Inputy = GUICtrlCreateInput("", 436, 42, 73, 21)
$Tab_Fx_OrdreNr_Inputy = GUICtrlCreateInput("", 518, 42, 121, 21)

Where x is 1 to 5 and y is 1 to 6

So i have 150 input/combo i would like to reset at ones, is there any way for me to do that without writing 150 lines of GuiCtrlSetData(Input, "")

Hope that some one have an simple solution, course 150 lines of code is :-S

Regards

/Rex

Link to comment
Share on other sites

If you assign the inputs to an Array instead, then you can loop through the Array. You'll have to figure out how to set the x,y,width,height of the controls though (could also use an array).

untested:

Dim $arrInputs[5][5]
For $x = 0 to 4
    For $y = 0 to 5
        $arr[$x][$y] = GUICtrlCreateInput()
    Next
Next

Or If you'd prefer not to redesign your gui code, then use a for loop and the Execute() func.

For $x = 1 to 5
    For $y = 1 to 6
        Execute("GUICtrlSetData($Tab_F" & $x & "_Customer_Input" & $y & ',""')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieCount_Input" & $y & ',""')
        ;etc...
    Next
Next
Edited by spudw2k
Link to comment
Share on other sites

If you assign the inputs to an Array instead, then you can loop through the Array. You'll have to figure out how to set the x,y,width,height of the controls though (could also use an array).

untested:

Dim $arrInputs[5][5]
For $x = 0 to 4
    For $y = 0 to 5
        $arr[$x][$y] = GUICtrlCreateInput()
    Next
Next

Or If you'd prefer not to redesign your gui code, then use a for loop and the Execute() func.

For $x = 1 to 5
    For $y = 1 to 6
        Execute("GUICtrlSetData($Tab_F" & $x & "_Customer_Input" & $y & ',""')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieCount_Input" & $y & ',""')
        ;etc...
    Next
Next

Hi spudw2k

I did try to use this

For $x = 1 to 6
    For $y = 1 to 5
        Execute("GUICtrlSetData($Tab_F" & $x & "_Customer_Input" & $y & ',""')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieCount_Input" & $y & ',""')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieType_Input" & $y & ',"PLL"')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieWeight_Input" & $y & ',""')
        Execute("GUICtrlSetData($Tab_F" & $x & "_CollieOrdreNr_Input" & $y & ',""')
    Next
Next

But nothing happens :) so i tryed to wrap it in a msg

Execute('MsgBox(0, "Test", "GUICtrlSetData($Tab_F" & $i & "_Customer_Input" & $i )')
and that did work.

Why can't i get your code to work?

Regards

/Rex

Link to comment
Share on other sites

It can be done also without Execute()

Dim $arr[5][5]
For $x = 0 to 4
    For $y = 0 to 4
        $arr[$x][$y] = GUICtrlCreateInput(...)
    Next
Next

; clear all inputs
For $x = 0 to 4
    For $y = 0 to 4
        GUICtrlSetData($arr[$x][$y],'')
    Next
Next
Edited by Zedna
Link to comment
Share on other sites

prob just syntax. try this perhaps?

Execute('"GUICtrlSetData($Tab_F" & $x & "_Customer_Input" & $y)')

It can be done also without Execute()

Dim $arr[5][5]
For $x = 0 to 4
    For $y = 0 to 4
        $arr[$x][$y] = GUICtrlCreateInput(...)
    Next
Next

; clear all inputs
For $x = 0 to 4
    For $y = 0 to 4
        GUICtrlSetData($arr[$x][$y],'')
    Next
Next

Bingo, that's how I'd prefer to do it, as I suggested in my first post. Edited by spudw2k
Link to comment
Share on other sites

@Both

No redesigning my GUI, all ready redesigned it 6 times now, course i kept forgetting some info fields and so :)

And i don't understand any of that arrayer thing any way, i always ending up here at the forum asking for help about it.

Cheers

/Rex

Link to comment
Share on other sites

@Both

No redesigning my GUI, all ready redesigned it 6 times now, course i kept forgetting some info fields and so :)

And i don't understand any of that arrayer thing any way, i always ending up here at the forum asking for help about it.

Cheers

/Rex

Arrays can be very useful.

http://www.autoitscript.com/wiki/Arrays

All you need to know about arrays.

Cherio

Edited by spudw2k
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...