atzoref Posted April 18, 2012 Share Posted April 18, 2012 Hi,I have a situation like this, to calculate this expression: MsgBox(0,"","9,913.223" * 2)The result it shows me is: 18 (instead of 19826.446)Or even:MsgBox(0,"",9,913.223 * 2)The result it shows me is: 9 (instead of 19826.446)What is the best way to calculte this when I have the number with the Comma (",")(I can delete the Comma from the string but I ask maybe there is another way..)Thanks Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Share Posted April 18, 2012 You have to remove the "," to get a valid number. Something like:MsgBox(0,"",stringreplace("9,913.223", ",", "") * 2) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
atzoref Posted April 18, 2012 Author Share Posted April 18, 2012 But sometimes the number in the string doesn't have the "," (if the number is under 1000) Is this method still work or there will be a problem with this? Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Share Posted April 18, 2012 Yes, this method will still work. It removes all "," from the string. If there is none, everything is still fine. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
acidman Posted April 18, 2012 Share Posted April 18, 2012 if its for math calculations try using the math functions included in autoit... like $Sumof = Number(95596.164 * 2) $Round = Round($Sumof, 2) Msgbox(64, "title", $Round) [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Share Posted April 18, 2012 The OPs problem is not the math but the conversion part (string to number). Function Number stops converting the string to numbers when the first non numeric character is encountered. So $y = Number("24/7")returns 24 not 247. hence he has to remove the ";" bevor converting the string to a number. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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