 # Converting Strings to Integers

Hello!

Rookie RPA Developer here… So I’m currently building a bot, in which one of the parts involves using a “Get Text” to scrape a number from a website.

Once I have the number, I used an assign function to substring the “\$26,095.71” to get rid of the dollar sign and only keep “26,095.71” (see screenshot below)

Now… the part that I’m stuck on is that I want to now turn this string into an integer so I could perform mathematical equations on this number. (For example, I want to the multiply the current available cash by 1%)

How do I turn a string into an integer? 1 Like

@GTowerz
convert.ToDouble(“26,095.71” )

or convert.ToDouble(yourString)

1 Like

Create a Decimal variable and assign the value using below convert decimal to retain decimal values.

``````Convert.toDecimal(AvailableCash)
``````

Cheers!

convert.ToDouble(yourstring.replace("\$",""))

Hi
If the input is stored in a variable named strinput
Then use a assign activity like this
stroutput = System.Text.RegularExpressions.Regex.Match(strinput.ToString.Trim,”[0-9].*”).ToString

Now we will be able to convert that to integer or double value with this

dou_input = Convert.ToDouble(stroutput.ToString)

Where dou_input is a variable of type System.Double

Cheers @GTowerz

Hi,
I understand the convert function, but where exactly would I place it?
Would I create another assign function and assign that function to a variable?
If so… what variable type would I assign to the new variable?

1 - create a local variable with type as ‘Decimal’ - ex - dec_availCash
2 - using assign activity -> dec_availCash = Convert.toDecimal(AvailableCash)