# square root

## Recommended Posts

I need get the square root for a simple calculator..

The code is here:

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <GuiStatusBar.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

\$Form1 = GUICreate("Form1", 615, 438, 192, 124)

\$Input1 = GUICtrlCreateInput("coeA", 88, 40, 41, 21)

\$Input2 = GUICtrlCreateInput("coeB", 88, 64, 41, 21)

\$Input3 = GUICtrlCreateInput("coeC", 88, 88, 41, 21)

\$Label1 = GUICtrlCreateLabel("Coeficiente A", 8, 40, 67, 17)

\$Label2 = GUICtrlCreateLabel("Coeficiente B", 8, 64, 67, 17)

\$Label3 = GUICtrlCreateLabel("Coeficiente C", 8, 88, 67, 17)

\$Label4 = GUICtrlCreateLabel("Valor de Delta :", 8, 128, 77, 17)

\$StatusBar1 = _GUICtrlStatusBar_Create(\$Form1)

\$Label5 = GUICtrlCreateLabel("Calculadora de equações do 2º Grau", 8, 8, 179, 17)

\$delta = -\$Input2 - 4 * \$Input1 * \$Input3

\$Label6 = GUICtrlCreateLabel(\$delta, 88, 128, 36, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

\$nMsg = GUIGetMsg()

Switch \$nMsg

Case \$GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

`Sqrt()`

##### Share on other sites

`Sqrt()`

Thanks,now i have problem for show result for user,the code

```#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
\$Form1 = GUICreate("Form1", 615, 438, 192, 124)
\$Input1 = GUICtrlCreateInput("", 88, 40, 41, 21)
\$Input2 = GUICtrlCreateInput("", 88, 64, 41, 21)
\$Input3 = GUICtrlCreateInput("", 88, 88, 41, 21)
\$Label1 = GUICtrlCreateLabel("Coeficiente A", 8, 40, 67, 17)
\$Label2 = GUICtrlCreateLabel("Coeficiente B", 8, 64, 67, 17)
\$Label3 = GUICtrlCreateLabel("Coeficiente C", 8, 88, 67, 17)
\$Label4 = GUICtrlCreateLabel("Valor de Delta :", 8, 128, 77, 17)
\$StatusBar1 = _GUICtrlStatusBar_Create(\$Form1)
\$Label5 = GUICtrlCreateLabel("Calculadora de equações do 2º Grau", 8, 8, 179, 17)
\$delta1 = \$Input2 * \$Input2
\$delta2 = - 4 * \$Input1 * \$Input3
\$delta3 = \$delta1 + \$delta2
\$Label6 = GUICtrlCreateLabel(\$delta3, 88, 128, 36, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd```

Thanks for help me

##### Share on other sites

Thanks,now i have problem for show result for user,the code

What? You don't have a Sqrt() function anywhere in that code. Show what result?

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

##### Share on other sites

What? You don't have a Sqrt() function anywhere in that code. Show what result?

Sqrt() is needed in second part of program,i need solve this first

Thanks

##### Share on other sites

Solve what? The code you posted calculates a value in \$delta3, the creates a label to display it in \$Label6. What else did you want it to do?

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

##### Share on other sites

Solve what? The code you posted calculates a value in \$delta3, the creates a label to display it in \$Label6. What else did you want it to do?

but when i change the value in inputbox the value returned is same...

##### Share on other sites

Ah, I see one point of confusion there. You are doing calculations with Control IDs of the inputs (\$Input1 thru \$Input3) instead of the values from those controls. Put the code inside your While/WEnd loop to GuiCtrlRead() the inputs and then GuiCtrlSetData() to put the updated result in \$Label6.

```#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
\$Form1 = GUICreate("Form1", 615, 438, 192, 124)
\$Input1 = GUICtrlCreateInput("", 88, 40, 41, 21)
\$Input2 = GUICtrlCreateInput("", 88, 64, 41, 21)
\$Input3 = GUICtrlCreateInput("", 88, 88, 41, 21)
\$Label1 = GUICtrlCreateLabel("Coeficiente A", 8, 40, 67, 17)
\$Label2 = GUICtrlCreateLabel("Coeficiente B", 8, 64, 67, 17)
\$Label3 = GUICtrlCreateLabel("Coeficiente C", 8, 88, 67, 17)
\$Label4 = GUICtrlCreateLabel("Valor de Delta :", 8, 128, 77, 17)
\$StatusBar1 = _GUICtrlStatusBar_Create(\$Form1)
\$Label5 = GUICtrlCreateLabel("Calculadora de equações do 2º Grau", 8, 8, 179, 17)
\$Label6 = GUICtrlCreateLabel("", 88, 128, 36, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit

EndSwitch

\$delta3 = \$delta1 + \$delta2
GUICtrlSetData(\$Label6, \$delta3)
WEnd```

Note the value read from the input control is sent through Number() to convert it from a string to number variable type.

Edited by PsaltyDS

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

##### Share on other sites

OOOw he is the superprogrammer,thanks you solve my problem

##### Share on other sites

OOOw he is the superprogrammer,thanks you solve my problem

Nah, a super programmer would only update the control when the value changes to avoid a flicker effect.

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Nah, a super programmer would only update the control when the value changes to avoid a flicker effect.

That step was intentionally left as an exercise for the student.

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

##### Share on other sites

MMMMMM,

the result is blinking but is legible,now i go complete the calculator..

Thanks man..

##### Share on other sites

i cant solve the flicking..i need use what function?please post just the function now!No post the code,i need learn

thanks

##### Share on other sites

Try this change to the code PsaltyDS posted, see the lines marked with <<<<<<<<<<<<<<<<<<<<

```#endregion ### END Koda GUI section ###
\$temp = "" ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit

EndSwitch

\$delta3 = \$delta1 + \$delta2
If \$delta3 <> \$temp then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetData(\$Label6, \$delta3)
\$Temp = \$delta3 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Endif
WEnd```

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

## Create an account

Register a new account