Heroe Posted January 26, 2018 Share Posted January 26, 2018 Hi guys, I've got a simple question and I can't understand it. I need to verify an amount that is between 750 and 1000. It is the only part of the code that does not work. I have isolated that same part of the entire code and it still does not work. When I put an amount, for example, 800, the code does not recognize it and can not make the condition. I think it's not a code error. Here is the code: expandcollapse popup#include <array.au3> #include <file.au3> #RequireAdmin #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Working...", 623, 403, 184, 109) $Label1 = GUICtrlCreateLabel("Introducir cantidad", 288, 40, 102, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Serif") $Input1 = GUICtrlCreateInput("0", 400, 40, 129, 21) $Label2 = GUICtrlCreateLabel("Cálculo:", 16, 136, 142, 17) $Label3 = GUICtrlCreateLabel("0000000000000000000000", 176, 137, 136, 17) $Label4 = GUICtrlCreateLabel("Cálculo2", 11, 178, 140, 17) $Label5 = GUICtrlCreateLabel("0000000000000000000000", 174, 182, 136, 17) $Label6 = GUICtrlCreateLabel("Cálculo3", 14, 219, 140, 17) $Label7 = GUICtrlCreateLabel("0000000000000000000000", 172, 216, 136, 17) $Button1 = GUICtrlCreateButton("¡Aceptar!", 232, 288, 177, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### global $cantidad = "0" global $cantidadF = "0" global $cantidadB = "0" global $cantidadD="0" global $cantidadE= "0" global $cantidad1000 = "0" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $button1 $cantidad=GuiCtrlRead ($input1) if $cantidad > "750" and $cantidad < "1000" Then $cantidad100 =$cantidad * "0.27" - ("250" * "0.07") - (("250") * "0.06") - (("500") * "0.05") - (($cantidad - "750") * "0.04") msgbox (0,"",$cantidad100) EndIf EndSwitch WEnd I think the error is from my computer or something similar, because I think the code is fine. It works with any amount but between 750 and 1000 does not work. Thanks in advance. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 26, 2018 Share Posted January 26, 2018 Remove the quotes around the numbers in the comparisons. If $cantidad > 750 And $cantidad < 1000 Then Heroe 1 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...
Developers Jos Posted January 26, 2018 Developers Share Posted January 26, 2018 You are comparing with a literal string, not a number. change that to: $cantidad = Number($cantidad) if $cantidad > 750 and $cantidad < 1000 Then Jos Heroe 1 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...
Heroe Posted January 26, 2018 Author Share Posted January 26, 2018 Thank you, guys, now it works. I feel so fool jajaja. Link to comment Share on other sites More sharing options...
jchd Posted January 27, 2018 Share Posted January 27, 2018 Moreover, "1000" < "750" < "800" due to how strings compare. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
iamtheky Posted January 27, 2018 Share Posted January 27, 2018 moreover, welcome to autoit msgbox(0, '' , .99999999999999995 = 1) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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