Split a string to two different variables, convert to int, and divide

I have a price range stored into a variable which I need to split, and then store them into two different variables so I can add and divide them among each other.

StringVaraible = “$1000 - $2000”

What I need to do:

  1. Remove the ‘-’ in the middle

  2. Remove the ‘$’ from the string

  3. Store 1000 and 2000 into separate variables (this is the hard part I think)

  4. Convert (those two variables^) to int

Thanks in advance

1 Like

@Sami_Syed Hello,

  1. Using String.Replace method replace $ the with nothing.

  2. Split the your String with respect to “-” then you will get array of 2 values.

array(0) contains “1000” and array(1) contains “2000”

  1. To that values to integer you can use below methods.

Convert.ToInt32(array(0)) this will give first array element in integer format

you can also below method for converting to integer format

Cint(array(0)) this will also give first array element in integer format


What is the method?

How do I split it to get an array like this

Please let me know. Sorry I am new to this and don’t know much of the syntax

1 Like


StringVariable="$1000 - $2000"


output will be “1000 - 2000”

String arr=StringVariable.Split({"-"},StringSplitOptions.RemoveEmptyEntries)

arr(0) contains “1000”
arr(1) contains “2000”


Thank you so much. Everything works
except for this:

I think it might be because of the logic I am using:

The error I get is “array is a type and cannot be used as an expression”\

Then I tried replacing ‘array(0)’ with a variable name (Data_FirstPrice) and got this error:
“option strict on disallows implicit conversions from integer to string”

Please let me know how I can convert it using the following logic

1 Like

@Sami_Syed can you share details of Convert to integer activity. what you have used there?


I am using the assign activity
and I have tried:

  • Convert.Toint32(Data_FirstPrice)

  • Convert.ToInt32(array(0))

  • Cint(array(0))

1 Like

@Sami_Syed Point your mouse to the blue on Convert to integer activity. Share the message here.

1 Like

1 Like

@Sami_Syed Data_FirstPrice variable is of string type. Your assigning integer value to string variable because of this your getting error.
Change the variable type to integer or Better Use new integer variable in this step so that previous assignment activities wont be affected.

If in previous step if you have used integer variable then in message box you to use string conversion.

like urintvariable.ToString

Message box accepts string variables only, other types variable have to be converted to string for using those in message box


Thank you so much!

I used this method and instead of int I decided to change to double (for some reason it wouldn’t let me divide two ints). Everything works perfect now


@Sami_Syed that’s great


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