Jump to content



Photo

complex issue in calculation


  • Please log in to reply
7 replies to this topic

#1 forever0donotknowme

forever0donotknowme

    Prodigy

  • Active Members
  • PipPipPip
  • 163 posts

Posted 18 March 2012 - 03:54 AM

hi my friends

really this script let me think along about reason of wrong result

Plain Text         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 316, 282, 246) $Input1 = GUICtrlCreateInput("", 184, 176, 65, 21) $Input2 = GUICtrlCreateInput("", 112, 176, 65, 21) $Button1 = GUICtrlCreateButton("result", 48, 248, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ###    $Input4 = $Input1*20   $Input5 = $Input2*20*20   $Input3 =$Input4 + $Input5 While 1 $nMsg = GUIGetMsg() Switch $nMsg   Case $GUI_EVENT_CLOSE    Exit Case $Button1 MsgBox(0,"result is",$Input3) EndSwitch WEnd






#2 Spiff59

Spiff59

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,312 posts

Posted 18 March 2012 - 06:00 AM

The variables $Input1 and $Input2 are control ID's returned by the GUICtrlCreateInput() statements. They are used to access the control. They do not contain the value of the data within the control. Use GUICtrlRead($Input1) to get the value within the field. It's all in the help file...

#3 Rogue5099

Rogue5099

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 313 posts

Posted 18 March 2012 - 10:51 AM

Not only do you need GUICtrlRead like Spiff59 said but you also need to move $Input4,5,3 after they hit button "result". Even with GUICtrlRead before they hit the button you will be reading an empty Control.

AutoIt         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 316, 282, 246) $Input1 = GUICtrlCreateInput("", 184, 176, 65, 21) $Input2 = GUICtrlCreateInput("", 112, 176, 65, 21) $Button1 = GUICtrlCreateButton("result", 48, 248, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input4 = GUICtrlRead($Input1) * 20 $Input5 = GUICtrlRead($Input2) * 20^2 $Input3 = $Input4 + $Input5 MsgBox(0, "result is", $Input3) EndSwitch WEnd


#4 forever0donotknowme

forever0donotknowme

    Prodigy

  • Active Members
  • PipPipPip
  • 163 posts

Posted 29 March 2012 - 01:41 PM

Not only do you need GUICtrlRead like Spiff59 said but you also need to move $Input4,5,3 after they hit button "result". Even with GUICtrlRead before they hit the button you will be reading an empty Control.

AutoIt         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 316, 282, 246) $Input1 = GUICtrlCreateInput("", 184, 176, 65, 21) $Input2 = GUICtrlCreateInput("", 112, 176, 65, 21) $Button1 = GUICtrlCreateButton("result", 48, 248, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input4 = GUICtrlRead($Input1) * 20 $Input5 = GUICtrlRead($Input2) * 20^2 $Input3 = $Input4 + $Input5 MsgBox(0, "result is", $Input3) EndSwitch WEnd

thanks my sir,

but i do not want any user to enter letters or symbols in input box , just i want input box contain only numbers from 0 to 9, what is script can execute this

#5 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,820 posts

Posted 29 March 2012 - 01:46 PM

thanks my sir,

but i do not want any user to enter letters or symbols in input box , just i want input box contain only numbers from 0 to 9, what is script can execute this

Add this style to the input creation line - $ES_NUMBER

Edited by BrewManNH, 29 March 2012 - 01:46 PM.

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#6 forever0donotknowme

forever0donotknowme

    Prodigy

  • Active Members
  • PipPipPip
  • 163 posts

Posted 29 March 2012 - 01:48 PM

Add this style to the input creation line - $ES_NUMBER


i do not understand you

can u explain in above script

#7 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,820 posts

Posted 29 March 2012 - 01:50 PM

Click this link, look at the styles list for GUICtrlCreateInput/Edit http://www.autoitscript.com/autoit3/docs/appendix/GUIStyles.htm#Edit.

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#8 forever0donotknowme

forever0donotknowme

    Prodigy

  • Active Members
  • PipPipPip
  • 163 posts

Posted 29 March 2012 - 02:28 PM

Click this link, look at the styles list for GUICtrlCreateInput/Edit http://www.autoitscript.com/autoit3/docs/appendix/GUIStyles.htm#Edit.

thanks my sir,

i modify code
Plain Text         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 316, 282, 246) $Input1 = GUICtrlCreateInput("", 184, 176, 65, 21,0x2000) $Input2 = GUICtrlCreateInput("", 112, 176, 65, 21,0x2000) $Button1 = GUICtrlCreateButton("result", 48, 248, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input4 = GUICtrlRead($Input1) * 20 $Input5 = GUICtrlRead($Input2) * 20^2 $Input3 = $Input4 + $Input5 MsgBox(0, "result is", $Input3) EndSwitch WEnd



but can I change that message(it show when i press letter ) to another language instead of english language or other words( i try challenge experts from this forum hahahahah

Edited by forever0donotknowme, 29 March 2012 - 02:39 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users