I am new to Uipath, i struck in converting string to Integer.
here is the scenario: i am scraping value from my application i .e $100 , like wise i have 3 variables $100 , $20 and $20
now i want to do some mathematical function (1st variable * 2nd variable/100 = 3rd variable)… while executing am getting string variables cannot be multiplied error is showing…
so can some one please help me out me out how i can do this.
I’d advise against using integers to store monetary values, you’ll lose precision.
Decimal should be used for monetary values. Double is close, but it loses precision with large/very small numbers (and with multiplications it’s not that hard to get there).
For both I’d say using string.replace to get rid of currency number is not the best approach. It’s also safer to use .Parse (or .TryParse) instead of convert, as it allows specifying culture and number styles.
(requires System.Globalization namespace to be imported) decimalFromDollars = Decimal.Parse("$100", NumberStyles.Currency, CultureInfo.CreateSpecificCulture("en-US")); decimalFromEuro = Decimal.Parse("€100", NumberStyles.Currency, CultureInfo.CreateSpecificCulture("de-DE")); decimalFromPLN = Decimal.Parse("100 zł", NumberStyles.Currency, CultureInfo.CreateSpecificCulture("pl-PL"))
“Replace” is a member of strings so you just need to convert your Generic value to a string or use a String variable type.
“.ToString” will convert any non-string value to a string to be used with “Replace” or other string members. variable1.ToString.Replace( )
OK. I’m reading a CSV file and one of the fields (TaxID) has a dash and I’m trying to remove the dash.
I’ve used this: Convert.ToInt32(CSVCompanyTaxID.Replace(“-”, “”))–But i get an error saying Cannot assign from type ‘System.Int32’ to type ‘System.String’ in Assign acitivity ‘Company Tax ID Remove Dash Variable Generation’.
I’ve used some other expressions but nothing is working right now any suggestions?
Thanks. So here is the whole picture of what I’m trying to do:
I have the CSVCompanyTaxID as an argument and i have it as a String.
So my first step is to assign the CSVCompanyTaxID to the column in the CSV file. That works. But now I was asked to remove the dash in the field and that is when i put that conversion in my logic.
But i get errors.
The first error is:
The second error is:
The third error is:
So what am I needing to do? I know it is simple but I’ve ran out of ideas at the moment.