Combo Box Auslesen ??

  • Tach zusammen, stehe mal wieder vor einem Rätsel, das Ihr bestimmt schnell lösen könnt.

    Möchte von einer Combobox etwas auswählen und den Eintrag mit einer Variablen Vergleichen, aber irgendwie ruft er nicht mal meine Funktion auf, bzw wenn er sie mal aufruft, dann liest er das Combofeld nicht aus. Wo ist mein Fehler ??

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $x=1
    DIM $artikel[100]
    DIM $bestandalt[100]
    DIM $liste
    _lesen()
    _fuellen()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 633, 168, 192, 124)
    $Combo1 = GUICtrlCreateCombo($artikel[0], 32, 64, 329, 25)
    $Combo1 = GUICtrlSetData(-1, $liste, $artikel[0])
    $aktuell = GUICtrlCreateInput("aktuell", 384, 64, 49, 21)
    $neu = GUICtrlCreateInput("neu", 464, 64, 49, 21)
    $OK = GUICtrlCreateButton("Übernehmen", 536, 64, 81, 25, $WS_GROUP)
    $Exit = GUICtrlCreateButton("Beenden", 272, 112, 113, 33, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("TonerTyp auswählen:", 32, 40, 153, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("aktuell", 392, 40, 35, 17)
    $Label3 = GUICtrlCreateLabel("neu", 472, 40, 22, 17)
    $Label4 = GUICtrlCreateLabel("Tonerbestand", 400, 16, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    Case $Exit
    Exit

    Case $Combo1
    GUICtrlSetData ( $aktuell, _anzeigen())
    EndSwitch
    WEnd

    Func _lesen()

    While $x <= 99

    $artikel[$x] = IniRead ("\\printserver\c$\NSClient++\nrpe\Tonerstandplugin.ini", "TonerTyp"&$x, "Tonerartikel", "0")
    $bestandalt[$x] = IniRead ("\\printserver\c$\NSClient++\nrpe\Tonerstandplugin.ini", "TonerTyp"&$x, "Tonerbestand", "0")
    $x = $x + 1
    WEnd
    EndFunc
    Func _fuellen()
    $x = 1
    $liste = $artikel[$x]
    $x= 2

    While $x <= 99

    $liste = $liste &"|"& $artikel[$x]
    $x = $x +1
    WEnd
    EndFunc
    Func _anzeigen()
    $auswahl = GUICtrlRead ($Combo1)
    $i = 0
    $x =1


    While $i = 0

    If $auswahl = $artikel[$x] Then $i = 1
    $x = $x +1


    WEnd

    $toneraktuell = $bestandalt[$x]
    Return $toneraktuell
    EndFunc

    [/autoit]

    Bin wie immer für jeden Tipp dankbar.

    Grüße
    CrazyER

  • Combos auslesen kannst du mit GUICtrlread() und dann musst du eben abfragen.

    Spoiler anzeigen
    [autoit]

    If GUICtrlRead($Combo1)=$Dein_Vergleichswert Then
    ...
    EndIf

    [/autoit]


    Edit: Die Combo wird ausgelesen allerdings gibt die Funktion _anzeigen keinen Wert aus. Also weis AutoIt nicht welcher wert für $aktuell gesetzt werden soll.

    2 Mal editiert, zuletzt von Calypso (18. November 2009 um 17:38)

  • Zitat
    [autoit]


    ---
    $Combo1 = GUICtrlCreateCombo($artikel[0], 32, 64, 329, 25)
    $Combo1 = GUICtrlSetData(-1, $liste, $artikel[0])
    ---

    [/autoit]

    Jaja.. Ein Teufelskreis. Da GUICtrlSetData erfolgreich war, ist $Combo1 bei dir im Script immer "1".

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $x=1
    DIM $artikel[100]
    DIM $bestandalt[100]
    DIM $liste
    _lesen()
    _fuellen()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 633, 168, 192, 124)
    $Combo1 = GUICtrlCreateCombo($artikel[0], 32, 64, 329, 25)
    GUICtrlSetData(-1, $liste, $artikel[0])
    $aktuell = GUICtrlCreateInput("aktuell", 384, 64, 49, 21)
    $neu = GUICtrlCreateInput("neu", 464, 64, 49, 21)
    $OK = GUICtrlCreateButton("Übernehmen", 536, 64, 81, 25, $WS_GROUP)
    $Exit = GUICtrlCreateButton("Beenden", 272, 112, 113, 33, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("TonerTyp auswählen:", 32, 40, 153, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("aktuell", 392, 40, 35, 17)
    $Label3 = GUICtrlCreateLabel("neu", 472, 40, 22, 17)
    $Label4 = GUICtrlCreateLabel("Tonerbestand", 400, 16, 101, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    Case $Exit
    Exit

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

    Case $Combo1
    GUICtrlSetData ( $aktuell, _anzeigen())
    EndSwitch
    WEnd

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

    Func _lesen()

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

    While $x <= 99

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

    $artikel[$x] = IniRead ("\\printserver\c$\NSClient++\nrpe\Tonerstandplugin.ini", "TonerTyp"&$x, "Tonerartikel", "0")
    $bestandalt[$x] = IniRead ("\\printserver\c$\NSClient++\nrpe\Tonerstandplugin.ini", "TonerTyp"&$x, "Tonerbestand", "0")
    $x += 1
    WEnd
    EndFunc
    Func _fuellen()
    $x = 1
    $liste = $artikel[$x]
    $x = 2

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

    While $x <= 99

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

    $liste = $liste &"|"& $artikel[$x]
    $x += 1
    WEnd
    EndFunc
    Func _anzeigen()
    $auswahl = GUICtrlRead ($Combo1)
    $i = 0
    $x = 1

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

    While $i = 0

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

    If $auswahl = $artikel[$x] Then $i = 1
    $x += 1

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

    WEnd

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

    $toneraktuell = $bestandalt[$x]
    Return $toneraktuell
    EndFunc

    [/autoit]

    $x = $x + 1 geht viel cooler mit $x += 1
    Mal davon abgesehen, dass dur dir mit einer For $x = 0 to 100 Schleife statt dem While, die Zeile eh ganz weglassen kannst.