How to add numbert to string with decimal

Hi everyone,
while browsing a web tab, I need to collect an amount from a page.
This amount is collected as a “string”, and contains decimals.
ex: €35.00
I need to add €15 to this string, to use it later.

I removed the € symbol with a Replace
I converted the string to INT32.
But now I don’t know how to add the 15 to this variable.

Can anyone help me?

Hi @AaronMark

Try this

"€" & (Double.Parse(Input.Replace("€", "")) + 15.0).ToString("F2")

Regards,

@AaronMark

Assign activity 1:
AmountString = "€35.00" ' This is your original string
AmountString = AmountString.Replace("€", "") ' Remove the "€" symbol

Assign activity 2:
AmountInteger = Convert.ToInt32(AmountString) ' Convert the string to an integer

Assign activity 3:
AmountInteger = AmountInteger + 15 ' Add 15 to the integer

Hi @AaronMark

Try this:

Assign-> Input = "€35.00"

Assign-> Number = System.Text.RegularExpressions.Regex.Match(Input,"\d+\.?\d+").Value.Trim()

Assign-> Euro = System.Text.RegularExpressions.Regex.Match(Input,"€").Value.Trim()

Assign-> Output = Euro+(Decimal.Parse(Number)+15).ToString

Refer the below image for better understanding:

or

Assign-> Input = "€35.00"

Assign-> Output = "€"+(Decimal.Parse(Input.Replace("€",""))+15).ToString

Hope it helps!!

I’ve tried a few solutions.
It does not work.
I noticed that the bot collects the attribute as “€35,00”
The decimal is a comma.
I don’t know if it makes a difference.
With the solutions I tried, the total in the end is not €50 but 3515

image

Hi @AaronMark

Try this:

Assign-> Input = "€35,00"

Assign-> Output = "€"+(Decimal.Parse(Input.Replace("€","").Replace(",","."))+15).ToString

Hope it helep!!

@AaronMark

Try this

"€" & (Double.Parse(Input.Replace("€", "").Replace(",", "."), System.Globalization.CultureInfo.GetCultureInfo("en-US")) + 15.0).ToString("F2", System.Globalization.CultureInfo.GetCultureInfo("en-US"))

itworks
Thanks to all

Aaron

1 Like

It’s my pleasure @AaronMark

Happy Automation!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.