## Recommended Posts

This is probably realy easy but.

How do I make a script that will set "0" into my two input boxes "\$a" and "\$b"?

So when the user presses the "clear" button, the calculations will all use the initial values of 0 for both \$a and \$b?

Script below.

```Global \$GUI = GUICreate("Hypotenuse-Calculator", 600, 300)
GUISetBkColor(0x00E0FFFF)
GUICtrlCreatePic(@ScriptDir & "\images\triangle.gif",10,50, 200,200)
GUICtrlCreateLabel("Please Enter the length for the 2 values that you have.", 10, 10)
GUICtrlCreateLabel("Click the Calculate button when entered.", 10, 25)
GUICtrlCreateLabel("A", 255, 80)
\$a = GUICtrlCreateInput("", 220, 100, 60, 20)
GUICtrlCreateLabel("B", 315, 80)
\$b = GUICtrlCreateInput("", 290, 100, 60, 20)
\$calculate = GUICtrlCreateButton("Calculate", 530,260, 50)
\$clear = GUICtrlCreateButton("Clear", 470,260, 50)
\$answer1a = GUICtrlCreateLabel("A Squared" ,390, 100,70)
\$answer2a = GUICtrlCreateLabel("B Squared:", 390, 130,70)
\$answer3a = GUICtrlCreateLabel("A+B squared:", 390, 160,70)
\$answer4a = GUICtrlCreateLabel("Square rooted:", 390, 190,70)
\$answer5a = GUICtrlCreateLabel("Length of C:", 390, 210,70)
GUISetState(@SW_SHOW)
While 1
\$msg = GUIGetMsg()
If \$msg = \$GUI_EVENT_CLOSE Then ExitLoop
If \$msg = \$calculate Then
EndIf
Wend```

##### Share on other sites

Hi,

also added to accept only numbers.

```#include<GuiConstants.au3>
Global \$GUI = GUICreate("Hypotenuse-Calculator", 600, 300)
GUISetBkColor(0x00E0FFFF)
GUICtrlCreatePic(@ScriptDir & "\images\triangle.gif", 10, 50, 200, 200)
GUICtrlCreateLabel("Please Enter the length for the 2 values that you have.", 10, 10)
GUICtrlCreateLabel("Click the Calculate button when entered.", 10, 25)
GUICtrlCreateLabel("A", 255, 80)
\$a = GUICtrlCreateInput("", 220, 100, 60, 20,\$ES_NUMBER)
GUICtrlCreateLabel("B", 315, 80)
\$b = GUICtrlCreateInput("", 290, 100, 60, 20,\$ES_NUMBER)
\$calculate = GUICtrlCreateButton("Calculate", 530, 260, 50)
\$clear = GUICtrlCreateButton("Clear", 470, 260, 50)
\$answer1 = GUICtrlCreateLabel("", 465, 100, 73)
\$answer2 = GUICtrlCreateLabel("", 465, 130, 73)
\$answer3 = GUICtrlCreateLabel("", 465, 160, 73)
\$answer4 = GUICtrlCreateLabel("", 465, 190, 130)
\$answer5 = GUICtrlCreateLabel("", 465, 210, 130)
\$answer1a = GUICtrlCreateLabel("A Squared", 390, 100, 70)
\$answer2a = GUICtrlCreateLabel("B Squared:", 390, 130, 70)
\$answer3a = GUICtrlCreateLabel("A+B squared:", 390, 160, 70)
\$answer4a = GUICtrlCreateLabel("Square rooted:", 390, 190, 70)
\$answer5a = GUICtrlCreateLabel("Length of C:", 390, 210, 70)
GUISetState(@SW_SHOW)
While 1
\$msg = GUIGetMsg()
If \$msg = \$GUI_EVENT_CLOSE Then ExitLoop
If \$msg = \$calculate Then
EndIf
If \$msg = \$clear Then
GUICtrlSetData(\$a, "")
GUICtrlSetData(\$b, "")
EndIf
WEnd```

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

Many thanks for that!

Is it possible to also allow decimal places?

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

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