autow Posted November 3, 2010 Share Posted November 3, 2010 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 Link to comment Share on other sites More sharing options...
Sercankd Posted November 3, 2010 Share Posted November 3, 2010 Sqrt() Link to comment Share on other sites More sharing options...
autow Posted November 3, 2010 Author Share Posted November 3, 2010 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 Thanks,now i have problem for show result for user,the codeWhat? 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 Link to comment Share on other sites More sharing options...
autow Posted November 3, 2010 Author Share Posted November 3, 2010 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 firstThanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 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 Link to comment Share on other sites More sharing options...
autow Posted November 3, 2010 Author Share Posted November 3, 2010 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... Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 (edited) 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 $delta1 = Number(GUICtrlRead($Input2)) ^ 2 $delta2 = -4 * Number(GUICtrlRead($Input1)) * Number(GUICtrlRead($Input3)) $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 November 3, 2010 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 Link to comment Share on other sites More sharing options...
autow Posted November 3, 2010 Author Share Posted November 3, 2010 OOOw he is the superprogrammer,thanks you solve my problem Link to comment Share on other sites More sharing options...
Developers Jos Posted November 3, 2010 Developers Share Posted November 3, 2010 OOOw he is the superprogrammer,thanks you solve my problemNah, a super programmer would only update the control when the value changes to avoid a flicker effect. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 3, 2010 Share Posted November 3, 2010 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 Link to comment Share on other sites More sharing options...
autow Posted November 4, 2010 Author Share Posted November 4, 2010 MMMMMM, the result is blinking but is legible,now i go complete the calculator.. Thanks man.. Link to comment Share on other sites More sharing options...
autow Posted November 10, 2010 Author Share Posted November 10, 2010 i cant solve the flicking..i need use what function?please post just the function now!No post the code,i need learn thanks Link to comment Share on other sites More sharing options...
BrewManNH Posted November 10, 2010 Share Posted November 10, 2010 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 $delta1 = Number(GUICtrlRead($Input2)) ^ 2 $delta2 = -4 * Number(GUICtrlRead($Input1)) * Number(GUICtrlRead($Input3)) $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 GudeHow 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now