# 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

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

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