Jump to content

Why won't this work?


Go to solution Solved by TheSaint,

Recommended Posts

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

$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 24, 32, 265, 21)
$Input2 = GUICtrlCreateInput("Input2", 24, 80, 265, 21)
$Button1 = GUICtrlCreateButton("Button1", 296, 240, 225, 73)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If $Input1 > $Input2 Then
                MsgBox(0,"Test", "Greater")
            Else
                MsgBox(0, "Test", "Smaller")
            EndIf

    EndSwitch
WEnd

What I want is if I put 2 in input1 and 1 in input2 and press the button. the msgbox will show greater. But it shows smaller everytime

Link to comment
Share on other sites

You are just getting the ID of the Inputs.

You need to read the value you set in the Inputs.

Case $Button1
            If GUICtrlRead($Input1) > GUICtrlRead($Input2) Then
                MsgBox(0,"Test", "Greater")
            Else
                MsgBox(0, "Test", "Smaller")
            EndIf

You also aren't checking for when they are equal.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Solution

All up, you would be better off assigning what you read, to variables.

Case $Button1
            $val_1 = GUICtrlRead($Input1)
            $val_2 = GUICtrlRead($Input2)
            If $val_1 > $val_2 Then
                MsgBox(0,"Test", "Greater")
            ElseIf $val_1 < $val_2 Then
                MsgBox(0,"Test", "Smaller")
            Else
                MsgBox(0, "Test", "Equal")
            EndIf

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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...