Input auslesen

  • Hi Leute,
    habe ein kleines prob:
    Code:
    $Form1 = GUICreate("Form1", 268, 274, 397, 283)
    $Button1 = GUICtrlCreateButton("Bestätigen", 32, 152, 193, 57, 0)
    $Input1 = GUICtrlCreateInput("", 56, 72, 145, 21)
    $Label1 = GUICtrlCreateLabel("How old are you ? ", 48, 24, 192, 28)
    GUICtrlSetFont(-1, 14, 800, 2, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    Run (0)
    GUICtrlRead( $Input1)
    if $Input1 < 18 Then
    MsgBox(0,"Fenster","Zuuuuu ALt")
    ElseIf $Input1 > 18 Then
    MsgBox(0,"Fenster","Zuuuu Jung")
    ElseIf $Input1 = 18 Then
    MsgBox(0,"Fenster","Genau richtig")
    EndIf
    Exit


    EndSwitch
    WEnd


    So,jetzt will ich ,dass das Fenster mir bei <18 zu jung , >18 zu alt und bei =18 genau richtig anzeigt . Was hab ich falsch gemacht ? es kommt immer nur zu alt :(

  • Hi,


    Bitte das nächste Mal Spoiler u. AutoIt Code nutzen, die Schrift auch nicht so groß, du hast schon die richtige Funktion stehen u. nutzt denn noch die Variable?
    Die vergleich Operationen solltest du noch üben was größer u. kleiner als bedeutet.


    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    Global $Form1 = GUICreate("Form1", 268, 274, 397, 283)
    Local $Button1 = GUICtrlCreateButton("Bestätigen", 32, 152, 193, 57, 0)
    Local $Input1 = GUICtrlCreateInput("", 56, 72, 145, 21)
    Local $Label1 = GUICtrlCreateLabel("How old are you ? ", 48, 24, 192, 28)
    GUICtrlSetFont(-1, 14, 800, 2, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Button1
    If GUICtrlRead($Input1) > 18 Then
    MsgBox(0, "Fenster", "Zuuuuu ALt")
    ElseIf GUICtrlRead($Input1) < 18 Then
    MsgBox(0, "Fenster", "Zuuuu Jung")
    ElseIf GUICtrlRead($Input1) = 18 Then
    MsgBox(0, "Fenster", "Genau richtig")
    EndIf
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Lg kleiner

  • Sorry schreib sowas das erste mal ^^ , größer und kleiner hab ich aus. vertauscht
    Vielen dank
    prob gelöst

  • Hi Timm,
    das kann man auch kürzen:

    Spoiler anzeigen
    [autoit]


    GUICreate("Form1", 268, 274, 397, 283)
    $Button1 = GUICtrlCreateButton("Bestätigen", 32, 152, 193, 57)
    $Input1 = GUICtrlCreateInput("", 56, 72, 145, 21)
    $Label1 = GUICtrlCreateLabel("How old are you ? ", 48, 24, 192, 28)
    GUICtrlSetFont(-1, 14, 800, 2, "MS Sans Serif")
    GUISetState(@SW_SHOW)

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

    While 1
    Switch GUIGetMsg()
    Case -3
    Exit
    Case $Button1
    If GUICtrlRead($Input1) <> 18 Then
    MsgBox(0, "Error", "Falsches ALter!")
    Else
    MsgBox(0, "Hello", "Genau richtig!")
    EndIf
    EndSwitch
    WEnd

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