Jump to content

Help with Getting User input.


Recommended Posts

I have While/Wend loop searching for user input with a Switch statement. My form used a loop to generate 400+/- labels and this case statement evaluates them such as: Case $Label[1] Case $Label[2] is there a better way than typing out 400+/- case statements inside this while loop?

The loop:

While 1
    $nMsg = GUIGetMsg()
        
        Switch $nMsg
       
            Case $GUI_EVENT_CLOSE
                Exit
            
            Case $BtnAdd
                If GUICtrlRead($CropComboList) = "" then
                MsgBox(0, "Error", "You must select a crop from the combo box before adding a seeding area to the list")
                ElseIf GUICtrlRead($CropComboList) = "Select a Crop" then
                MsgBox(0, "Error", "You must select a crop from the combo box before adding a seeding area to the list")
                EndIf
    
                GUICtrlSetData($AreaList, "Area " & $AreaCount & ": " & GUICtrlRead($CropComboList))
                $AreaCount = $AreaCount + 1
            
            Case $BtnExit
                Call("Terminate")   

            Case $Label1[1]
                MsgBox(0,"", "You pushed the Button 1" & $Label1[1])
                GUICtrlSetBkColor($Label1[1], $GUI_BKCOLOR_TRANSPARENT)
            
            Case $Label1[2]
                MsgBox(0,"", "You pushed the Button 2" & $Label1[2])
                GUICtrlSetBkColor($Label1[2], $GUI_BKCOLOR_TRANSPARENT)
            
            Case $Label1[3]
                MsgBox(0,"", "You pushed the Button 3" & $Label1[3])
                GUICtrlSetBkColor($Label1[3], $GUI_BKCOLOR_TRANSPARENT)
            
            Case $Label1[4]
                MsgBox(0,"", "You pushed the Button 4" & $Label1[4])
                GUICtrlSetBkColor($Label1[4], $GUI_BKCOLOR_TRANSPARENT)
                
        EndSwitch
    WEnd
Link to comment
Share on other sites

Back to the first response. I think you need to use a for next loop

for $i=1 to 400
        Case $Label1[1]
        MsgBox(0,"", "You pushed the Button "&$i& $Label1[$i])
        GUICtrlSetBkColor($Label1[$i], $GUI_BKCOLOR_TRANSPARENT)
    Next
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...