Convert string to number-check string conatins any number

if String str=" ";
how to convert this to number?

Integer.parse(str) didn’t worked

convert.Int32(str) also didn’t worked

Why do you want to convert an empty space to number?

sometimes in UI either it will be given number , sometimes left blank or sometimes given zero

so check before converting it to number, If it is empty string. Only after that convert it or else directly pass the value without converting if its empty.

Hi @KarthikBallary
Do One Thing

Cint(Str.ToString.Contains(“your number”)).ToString

Ashwin S

I need to check what number it has

ok how to check if it contains number?

1 Like




Try like this to convert it number by removing spaces,

yourString.Split({" "}, StringSplitOptions.RemoveEmptyEntries)

So the expression be like this
int_output = IF(IsNumeric(str_input.ToString),Convert.ToInt32(str_input.ToString),0)
Where int_output is a variable of type int32 and it will get the converted int32 number or either a 0 value to it

Cheers @KarthikBallary


throwing syntax error


so this will convert “” to zero?

Yah just now changed it like this


Is it working @KarthikBallary

Need to check I will let you know.

if str="" it will convert to 0?

Yah that would either
Like first it will check whether it is a number or not
If it has any numerical value it will convert that
If not if just the str variable has only “” then it will give 0 or if it’s not a numerical value then also it will give us 0

Cheers @KarthikBallary

It is working fine for first loop, second loop throwing error-Object reference not set to an instance of an object.

It means the input string variable has no value in it
Kindly validate that once using a writeline activity before this conversion so that we can see in the output panel whether it shows any value or not
Cheers @KarthikBallary

1 Like