Jump to content

Get Data From Input And Calculate When Button Pressed


Recommended Posts

Hi

Just downloaded the program and looks really good - nice to create boxes, buttons, labels etc on GUI Windows

However - I am new to all this windows GUI stuff as I used to program in Standard BASIC with line numbers etc

Can someone give me a clue as to the code

All I want to do is get started with the code you need to enter some number in a text box, and then when you click the button, the result is displayed in another text box

I produced a GUI looking like this

-------------------------

#include <GUIConstants.au3>

GUICreate("Simple Calculator", 300, 150)

GUICtrlCreateInput( "Enter", 25, 25, 50, 20)

GUICtrlCreateButton( "Calculate", 100, 25, 75, 20)

GUICtrlCreateInput( "= Answer", 200, 25, 50, 20)

GUISetState (@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

-------------------------------

But - obviously this doesnt actually DO anything

Anyone give me a clue as to how to make the button take the input from first box - say times it by 5, and put answer in 2nd box

Would be grateful - thanks

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("Simple Calculator", 300, 150) 
$inp1 = GUICtrlCreateInput( "Enter", 25, 25, 50, 20)
$but1 = GUICtrlCreateButton( "Calculate", 100, 25, 75, 20)
$inp2 = GUICtrlCreateInput( "= Answer", 200, 25, 50, 20)
GUISetState (@SW_SHOW); will display an empty dialog box

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $but1 Then GUICtrlSetData($inp2, GUICtrlRead($inp1)^5)
Wend

Edited by mrbond007
Link to comment
Share on other sites

Thanks - now I can see where Im going

Would you know if there are any code snippets anywhere on the forum for anything

Thanks

You will find codes scattered around in the "General Help and Support" forum. You just have to search for them, but it won't be that easy.
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...