Input string was not in a correct format

Hello People,

I’m getting this error

Input string was not in a correct format
Exception Type: Format exception

when I try to compare if a variable1 < Int32.Parse(variable2) in a Flow Decision Element
The variable1 is a numer variable and variable2 is a String variable.

Please advise.

1 Like

Use Convert.ToInt32(variable2) to convert string to Int

Is it a whole number or a decimal? This error usually happens if you try to put a floating point number as an Int (whole number).

1 Like

Is a number variable

I tried with Convert.ToInt32(variable2) and didn’t work

And there’s no alpha or special characters at all? You might need to trim the spaces.

1 Like

Spaces don’t interfere (as long as they’re not any of those “special” spaces).

@desquivel - can you give some samples of the numbers?

Edit @ClaytonM
My bad, spaces can interfere if they are between characters.
I got it wrong because of instant correlation of Trim = String.Trim(), which only removes whitespace from beginning and end. I guess that’s what I got for replying too fast :wink:

No man, I set “0” as default to string variable2 and assign a number using screem scraping -> get visible text

Put a WriteLine just before it and see if it actually scrapes a number (screenshot would be nice as well, so we can help better).

Basically I’m getting the number of pages of a PDF file, so, I send CTRL + D with a HotKey Element then I use Screem Scraping and inside I use Get Visible Text and in the selector property use Attach to a live element…
but I realize sometimes the bot get the number of pages but other times don’t.
Exist a better way to get the number of pages of a PDF File?

Here I assign the number of pages in this case variable2.

If you put variable2.ToString in WriteLine, what’s the output?

I solved the bug, The problem was the screen scraping, The element was not capturing the information correctly.
Thank you all.

Hi, i have an error: Add to collection: Input string was not in a correct format.
I am trying to add some strings from a data table into a list of doubles. I write this in the Add to collection activity: convert.ToDouble(dt.Rows(index).Item(countLetter))
The problem is that when I run again without any modifications, it works there, but it stops me later with the same error.
Can you help me please?