Radio Buttons per Schleife abfragen

  • Hallo Community,
    ich habe mir eine GUI mit 18 Radiobuttons gebastelt. Es handelt sich hierbei um Spieltage. Es wird gefragt welcher Spieltag z.Zt läuft, dieser soll ausgegeben werden. Jetzt meine Frage: ist es möglich die Radiobuttons per Schleife abzufragen, oder muss ich wirklich abfragen:

    Code
    Case GUICtrlRead($Radio1) = $GUI_CHECKED
          	MsgBox(0,"","Es wurde der 1. Spieltag gewählt.")
    Case GUICtrlRead($Radio2) = $GUI_CHECKED
          	MsgBox(0,"","Es wurde der 2. Spieltag gewählt.")
    Case GUICtrlRead($Radio3) = $GUI_CHECKED
          	MsgBox(0,"","Es wurde der 3. Spieltag gewählt.")
    ...
    ...
    Case GUICtrlRead($Radio18) = $GUI_CHECKED
          	MsgBox(0,"","Es wurde der 18 Spieltag gewählt.")

    Schon einmal Danke
    MfG

    Einmal editiert, zuletzt von DGzRSBorkum (23. Mai 2010 um 14:35)

  • Spoiler anzeigen
    [autoit]

    #include <guiconstants.au3>
    Global $Radio[7]

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("", 100, 190)
    $Radio[1] = GUICtrlCreateRadio("a", 10, 10, 80, 20)
    $Radio[2] = GUICtrlCreateRadio("b", 10, 40, 80, 20)
    $Radio[3] = GUICtrlCreateRadio("c", 10, 70, 80, 20)
    $Radio[4] = GUICtrlCreateRadio("d", 10, 100, 80, 20)
    $Radio[5] = GUICtrlCreateRadio("e", 10, 130, 80, 20)
    $Radio[6] = GUICtrlCreateRadio("f", 10, 160, 80, 20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While True
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    For $i = 1 To 6
    If $msg = $Radio[$i] And GUICtrlRead($Radio[$i]) = $GUI_CHECKED Then
    MsgBox(0, "", "Es wurde der " & $i & ". Spieltag gewählt.")
    EndIf
    Next
    WEnd

    [/autoit]
  • du kannst doch hingehen, die radiobuttons in ein array packen und dann mit einer For....Next schleife abfragen

    Spoiler anzeigen
    [autoit]

    Global $radiobutton[18]

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 17
    If GUICtrlRead($radiobutton[$i]) = $GUI_CHECKED Then
    MsgBox(0,"","Es wurde der "& $i+1 & ". Spieltag gewählt.")
    EndIf
    Next

    [/autoit]

    da ein kleines beispiel

    //EDIT: ich sollte mal schneller schreiben

    Mfg. PCKing


    Mein PC

    CPU: AMD FX 8350 8x4.00GHz
    Ram: 8GB DDR3
    Grafikkarte: Nvidia Geforce GTX 960 (4GB)
    Festplatten: 500GB SSD 1TB HDD
    Laufwerk: Blueray RW+ Brenner

  • Ok, hätte ich auch selbst drauf kommen können :)
    Danke für die schnelle Hilfe.
    :thumbup: