eri Posted October 27, 2010 Posted October 27, 2010 Please correct my script.. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=G:\Form1.kxf $Form1 = GUICreate("Kalkulasi", 219, 186, 378, 178) GUISetBkColor(0x00FFFF) $Input1 = GUICtrlCreateInput("0", 90, 37, 122, 21) $Input2 = GUICtrlCreateInput("0", 89, 66, 122, 21) $Input3 = GUICtrlCreateInput("0", 89, 95, 122, 21) $Label1 = GUICtrlCreateLabel("Diameter", 8, 39, 60, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label2 = GUICtrlCreateLabel("Thickness", 8, 67, 65, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label3 = GUICtrlCreateLabel("Length", 8, 95, 46, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Input4 = GUICtrlCreateInput("", 8, 150, 204, 21) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label4 = GUICtrlCreateLabel("", 98, 140, 4, 4) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Radio1 = GUICtrlCreateRadio(" x..", 8, 8, 49, 17) $Radio2 = GUICtrlCreateRadio(" +..", 64, 8, 73, 17) GUICtrlSetState($radio1, $GUI_CHECKED) $Label5 = GUICtrlCreateLabel("Volume mm", 8, 130, 64, 20) GUICtrlSetFont(-1, 8, 800, 2, "Comic Sans MS") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Msg = GUIGetMsg() Select Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $c = $x * $y * $z If StringRegExp(StringLeft([$x-$y], 2)) Then ;<==== How to set $x-$y Only number not for word then show message in input 4 GUICtrlSetData($Input4, $c) Else GUICtrlSetData($Input4," Only Number Not Word") ; <====== EndIf Case BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $cz = $x + $y + $z GUICtrlSetData($Input4, $cz) EndSelect Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
AlmarM Posted October 27, 2010 Posted October 27, 2010 You want only numbers inside your GUICtrlRead?Start by setting a $ES_NUMBER style on your inputs. (Using #include <EditConstants.au3>) Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
JohnOne Posted October 27, 2010 Posted October 27, 2010 Sir! Yes Sir! AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
UEZ Posted October 27, 2010 Posted October 27, 2010 Try this:expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=G:\Form1.kxf $Form1 = GUICreate("Kalkulasi", 219, 186, 378, 178) GUISetBkColor(0x00FFFF) $Input1 = GUICtrlCreateInput("0", 90, 37, 122, 21) $Input2 = GUICtrlCreateInput("0", 89, 66, 122, 21) $Input3 = GUICtrlCreateInput("0", 89, 95, 122, 21) $Label1 = GUICtrlCreateLabel("Diameter", 8, 39, 60, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label2 = GUICtrlCreateLabel("Thickness", 8, 67, 65, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label3 = GUICtrlCreateLabel("Length", 8, 95, 46, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Input4 = GUICtrlCreateInput("", 8, 150, 204, 21) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label4 = GUICtrlCreateLabel("", 98, 140, 4, 4) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Radio1 = GUICtrlCreateRadio(" x..", 8, 8, 49, 17) $Radio2 = GUICtrlCreateRadio(" +..", 64, 8, 73, 17) GUICtrlSetState($radio1, $GUI_CHECKED) $Label5 = GUICtrlCreateLabel("Volume mm", 8, 130, 64, 20) GUICtrlSetFont(-1, 8, 800, 2, "Comic Sans MS") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 $Msg = GUIGetMsg() Select Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $c = $x * $y * $z ;~ If StringRegExp(StringLeft([$x-$y], 2)) Then ;<==== How to set $x-$y Only number not for word then show message in input 4 ;~ GUICtrlSetData($Input4, $c) ;~ Else ;~ GUICtrlSetData($Input4," Only Number Not Word") ; <====== ;~ EndIf Case BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $cz = $x + $y + $z GUICtrlSetData($Input4, $cz) EndSelect Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $inp, $integer $chk = BitAND($wParam, 0x0000FFFF) Switch $chk Case $Input1 $inp = GUICtrlRead($Input1) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input1, $integer) Case $Input2 $inp = GUICtrlRead($Input2) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input2, $integer) Case $Input3 $inp = GUICtrlRead($Input3) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input3, $integer) EndSwitch Return $GUI_RUNDEFMSG EndFuncBr,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
eri Posted October 27, 2010 Author Posted October 27, 2010 Try this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=G:\Form1.kxf $Form1 = GUICreate("Kalkulasi", 219, 186, 378, 178) GUISetBkColor(0x00FFFF) $Input1 = GUICtrlCreateInput("0", 90, 37, 122, 21) $Input2 = GUICtrlCreateInput("0", 89, 66, 122, 21) $Input3 = GUICtrlCreateInput("0", 89, 95, 122, 21) $Label1 = GUICtrlCreateLabel("Diameter", 8, 39, 60, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label2 = GUICtrlCreateLabel("Thickness", 8, 67, 65, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label3 = GUICtrlCreateLabel("Length", 8, 95, 46, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Input4 = GUICtrlCreateInput("", 8, 150, 204, 21) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label4 = GUICtrlCreateLabel("", 98, 140, 4, 4) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Radio1 = GUICtrlCreateRadio(" x..", 8, 8, 49, 17) $Radio2 = GUICtrlCreateRadio(" +..", 64, 8, 73, 17) GUICtrlSetState($radio1, $GUI_CHECKED) $Label5 = GUICtrlCreateLabel("Volume mm", 8, 130, 64, 20) GUICtrlSetFont(-1, 8, 800, 2, "Comic Sans MS") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 $Msg = GUIGetMsg() Select Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $c = $x * $y * $z ;~ If StringRegExp(StringLeft([$x-$y], 2)) Then ;<==== How to set $x-$y Only number not for word then show message in input 4 ;~ GUICtrlSetData($Input4, $c) ;~ Else ;~ GUICtrlSetData($Input4," Only Number Not Word") ; <====== ;~ EndIf Case BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $cz = $x + $y + $z GUICtrlSetData($Input4, $cz) EndSelect Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $inp, $integer $chk = BitAND($wParam, 0x0000FFFF) Switch $chk Case $Input1 $inp = GUICtrlRead($Input1) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input1, $integer) Case $Input2 $inp = GUICtrlRead($Input2) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input2, $integer) Case $Input3 $inp = GUICtrlRead($Input3) $integer = StringRegExpReplace($inp, "[^0-9]", "") GUICtrlSetData($Input3, $integer) EndSwitch Return $GUI_RUNDEFMSG EndFunc Br, UEZ Thank's UEZ...
UEZ Posted October 27, 2010 Posted October 27, 2010 Indeed, even shorter with suggestion from AlmarM ($ES_NUMBER):expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=G:\Form1.kxf $Form1 = GUICreate("Kalkulasi", 219, 186, 378, 178) GUISetBkColor(0x00FFFF) $Input1 = GUICtrlCreateInput("0", 90, 37, 122, 21, $ES_NUMBER) $Input2 = GUICtrlCreateInput("0", 89, 66, 122, 21, $ES_NUMBER) $Input3 = GUICtrlCreateInput("0", 89, 95, 122, 21, $ES_NUMBER) $Label1 = GUICtrlCreateLabel("Diameter", 8, 39, 60, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label2 = GUICtrlCreateLabel("Thickness", 8, 67, 65, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label3 = GUICtrlCreateLabel("Length", 8, 95, 46, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Input4 = GUICtrlCreateInput("", 8, 150, 204, 21) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label4 = GUICtrlCreateLabel("", 98, 140, 4, 4) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Radio1 = GUICtrlCreateRadio(" x..", 8, 8, 49, 17) $Radio2 = GUICtrlCreateRadio(" +..", 64, 8, 73, 17) GUICtrlSetState($radio1, $GUI_CHECKED) $Label5 = GUICtrlCreateLabel("Volume mm", 8, 130, 64, 20) GUICtrlSetFont(-1, 8, 800, 2, "Comic Sans MS") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Msg = GUIGetMsg() Select Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $c = $x * $y * $z Case BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED $x = GUICtrlRead ($Input1) $y = GUICtrlRead ($Input2) $z = GUICtrlRead ($Input3) $cz = $x + $y + $z GUICtrlSetData($Input4, $cz) EndSelect Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndBr,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
JoHanatCent Posted October 27, 2010 Posted October 27, 2010 (edited) Is there a way to allow decimal points in the above? Edit: Don't wory IsNumber(4.2) does it for me - Tx Even better: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=G:\Form1.kxf $Form1 = GUICreate("Kalkulasi", 219, 186, 378, 178) GUISetBkColor(0x00FFFF) $Input1 = GUICtrlCreateInput("0", 90, 37, 122, 21) $Input2 = GUICtrlCreateInput("0", 89, 66, 122, 21) $Input3 = GUICtrlCreateInput("0", 89, 95, 122, 21) $Label1 = GUICtrlCreateLabel("Diameter", 8, 39, 60, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label2 = GUICtrlCreateLabel("Thickness", 8, 67, 65, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Label3 = GUICtrlCreateLabel("Length", 8, 95, 46, 23) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Input4 = GUICtrlCreateInput("", 8, 150, 204, 21) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label4 = GUICtrlCreateLabel("", 98, 140, 4, 4) GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS") $Radio1 = GUICtrlCreateRadio(" x..", 8, 8, 49, 17) $Radio2 = GUICtrlCreateRadio(" +..", 64, 8, 73, 17) GUICtrlSetState($radio1, $GUI_CHECKED) $Label5 = GUICtrlCreateLabel("Volume mm", 8, 130, 64, 20) GUICtrlSetFont(-1, 8, 800, 2, "Comic Sans MS") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Msg = GUIGetMsg() Select Case BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED $x = Number(GUICtrlRead ($Input1)) $y = Number(GUICtrlRead ($Input2)) $z = Number(GUICtrlRead ($Input3)) $c = $x * $y * $z If $c >0 Then ;<==== How to set $x-$y Only number not for word then show message in input 4 GUICtrlSetData($Input4, $c) Else GUICtrlSetData($Input4," Only Numbers Bigger than Zero") ; <====== EndIf Case BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED $x = Number(GUICtrlRead ($Input1)) $y = Number(GUICtrlRead ($Input2)) $z = Number(GUICtrlRead ($Input3)) $c = $x + $y + $z If $c >0 Then ;<==== How to set $x-$y Only number not for word then show message in input 4 GUICtrlSetData($Input4, $c) Else GUICtrlSetData($Input4," Only Numbers Bigger than Zero") ; <====== EndIf EndSelect Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited October 27, 2010 by JoHanatCent
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