# Math problems

## Recommended Posts

Hello guys, I'm working on a large code and I went to add a little calculator for my Gui.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Exiting")
GuiCreate("URCB v.2.0 by Frit", 180, 190)

\$Check1 = GUICtrlCreateCheckbox("Ativar", 20, 40, 60, 30)
\$input = GUICtrlCreateInput("Begining", 10, 80, 160, 20)
\$input2 = GUICtrlCreateInput("End", 10, 110, 160, 20)
\$button = GUICtrlCreateButton ("Calculate", 10, 140)
\$resposta = GUICtrlCreateLabel ("", 100, 145, 50, 20)
GuiSetState()

While 1
If GUIGetMsg() = \$button Then
GUICtrlSetData(\$resposta, \$input2 - \$input)
Endif
WEnd

The problem is that I always get a random number, doesn't matter which operation I make. In this case, I get a 1.

Any ideas?

Edited by Frit

##### Share on other sites

Hello guys, I'm working on a large code and I went to add a little calculator for my Gui.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Exiting")
GuiCreate("URCB v.2.0 by Frit", 180, 190)

\$Check1 = GUICtrlCreateCheckbox("Ativar", 20, 40, 60, 30)
\$input = GUICtrlCreateInput("Begining", 10, 80, 160, 20)
\$input2 = GUICtrlCreateInput("End", 10, 110, 160, 20)
\$button = GUICtrlCreateButton ("Calculate", 10, 140)
\$resposta = GUICtrlCreateLabel ("", 100, 145, 50, 20)
GuiSetState()

While 1
If GUIGetMsg() = \$button Then
GUICtrlSetData(\$resposta, \$input2 - \$input)
Endif
WEnd

The problem is that I always get a random number, doesn't matter which operation I make. In this case, I get a 1.

Any ideas?

The variables you are doing the math with contain the control IDs of the input boxes, not the content of the boxes. Use their control IDs to read them with GuiCtrlRead():

While 1
If GUIGetMsg() = \$button Then
Endif
WEnd

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...