If: Input string was not in a correct format

Hi all,

I am having difficulty with applying a condition within the IF activity. As i run into the following error:
If: Input string was not in a correct format.

I want to check the variables (two columns - two variables) in each row from a data table to make sure it is in between -1<=variable <=1

(Integer.Parse(row(1).ToString)>=-1 and Integer.Parse(row(1).ToString)<=1) and (Integer.Parse(row(2).ToString)>=-1 and Integer.Parse(row(2).ToString)<=1)

Any assistance would be greatly appreciated.

Hi @chend,
Use the below condition
(Convert.ToInt32(row(1).ToString)>=-1 and Convert.ToInt32(row(1).ToString)<=1) and (Convert.ToInt32(row(2).ToString)>=-1 and Convert.ToInt32(row(2).ToString)<=1)

Integer.parse will not handle the null value so it may throw the exception so use Conversation.ToInt32


1 Like

I did a work around where i assigned the var then re-assign as an integer, which worked.
However, your method appears a lot cleaner and nicer. I will give it a try.

1 Like