Input string was not in a correct format


#1

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.


#2

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


#3

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).


#4

Is a number variable


#5

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


#6

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


#7

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:


#8

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


#9

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).


#10

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?


#11

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


#12

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


#13

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


#14

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?