Bitnugger

_ConvertStrNumOp($sNum1, $sNum2, $sOperator)

May 6th, 2020
332
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <WinAPILocale.au3>
  2. Local $sNumber1 = '1.856,83', $sNumber2 = '469,99', $sNumber3 = '1.386,84'
  3. ConsoleWrite(StringFormat('> %-10s - %-10s = ', $sNumber1, $sNumber2) & _ConvertStrNumOp($sNumber1, $sNumber2, '-') & @CRLF) ; $sNumber1 - $sNumber2
  4. ConsoleWrite(StringFormat('> %-10s + %-10s = ', $sNumber3, $sNumber2) & _ConvertStrNumOp($sNumber3, $sNumber2, '+') & @CRLF) ; $sNumber3 + $sNumber2
  5.  
  6. Func _ConvertStrNumOp($sNum1, $sNum2, $sOperator)
  7.     $sNum1 = StringReplace(StringReplace($sNum1, '.', ''), ',', '.')
  8.     $sNum2 = StringReplace(StringReplace($sNum2, '.', ''), ',', '.')
  9.     Return _WinAPI_GetNumberFormat(0, Execute($sNum1 & $sOperator & $sNum2), _WinAPI_CreateNumberFormatInfo(2, 0, 3, ',', '.', 0))
  10. EndFunc
RAW Paste Data