Jump to content

GUI Input help please?


Ultima2
 Share

Recommended Posts

Hi Im trying to create a GUI where one can put in a value and it will return in a MsgBox with the value added by some random value like 2.

#include <GUIConstants.au3>

GUICreate("test",300,250)
$exitbutton = GUICtrlCreateButton("Exit", 50, 70)
$value = GUICtrlCreateInput("",4,25,200,25)
$okbutton = GUICtrlCreateButton("ok", 2, 200)
GUISetState()

While 1
    $msg = GUIGetmsg()
    Select
        Case $msg = $okbutton 
        $value += 3
        ExitLoop
        
        Case $msg = $exitbutton
        ExitLoop
    EndSelect
WEnd
MsgBox(0,"The value is", $value)

Yea Im pretty sure I messed up somewhere. When I put a value in, it always return 7?! What's the correct way to write this? Dont be too harsh :)

Link to comment
Share on other sites

Hi Im trying to create a GUI where one can put in a value and it will return in a MsgBox with the value added by some random value like 2.

#include <GUIConstants.au3>

GUICreate("test",300,250)
$exitbutton = GUICtrlCreateButton("Exit", 50, 70)
$value = GUICtrlCreateInput("",4,25,200,25)
$okbutton = GUICtrlCreateButton("ok", 2, 200)
GUISetState()

While 1
    $msg = GUIGetmsg()
    Select
        Case $msg = $okbutton 
        $value += 3
        ExitLoop
        
        Case $msg = $exitbutton
        ExitLoop
    EndSelect
WEnd
MsgBox(0,"The value is", $value)

Yea Im pretty sure I messed up somewhere. When I put a value in, it always return 7?! What's the correct way to write this? Dont be too harsh :)

try this

#include <GUIConstants.au3>

GUICreate("test",300,250)
$exitbutton = GUICtrlCreateButton("Exit", 50, 70)
$value = GUICtrlCreateInput("",4,25,200,25)
$okbutton = GUICtrlCreateButton("ok", 2, 200)
GUISetState()

While 1
    $msg = GUIGetmsg()
    Select
        Case $msg = $okbutton 
        GuiCtrlSetData($Value,Number(GuiCtrlRead($Value))+3)
        ExitLoop
        
        Case $msg = $exitbutton
        ExitLoop
    EndSelect
WEnd
MsgBox(0,"The value is", GuiCtrlRead($Value))

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Link to comment
Share on other sites

Hey,

this works fine :)

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

GUICreate("test",300,250)
$exitbutton = GUICtrlCreateButton("Exit", 50, 70)
$hValue = GUICtrlCreateInput("",4,25,200,25, $ES_NUMBER)
$okbutton = GUICtrlCreateButton("ok", 2, 200)
GUISetState()

While 1
    $msg = GUIGetmsg()
    Select
        Case $msg = $okbutton
    ; $hValue is the handle to GUICtrlCreateInput, to get the data entered in GUICtrlCreateInput use GuiCtrlRead
        $iValue = GUICtrlRead($hValue)
        $iValue += 3
        ExitLoop
        
        Case $msg = $exitbutton
        ExitLoop
    EndSelect
WEnd
MsgBox(0,"The value is", $iValue)
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...