Sign in to follow this  
Followers 0
Ultima2

GUI Input help please?

4 posts in this topic

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 :)

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Thank you very much, now it works :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0