How to convert string variable to interger?


I scraped my application screen and save the value into a variable.
I used Get OCR Text to get the text and stored it as a variable.

Then I passed the argument to another workflow. However, my application will only allow numbers to be typed into the field.

Is there another way of scraping my application and saving the field as a number instead of a string? Or how do i convert the string variable into an integer variable?

I’ve tried changing the type to Int32 and Generic but both did not work.

1 Like

Try converting the string to INT using this @happygal321

CType(string you have, Integer)

1 Like

Welcome to uipath community
Usually we use TYPE INTO activity which will take only STRING as input
—so even though we convert that string extracted to integer with
Convert.ToInt32(yourstringvariable) we need to mention that as string while typing into the field using .ToString added at the end

So I hope we can directly mention the get text variable with .Tostring at the end so that it will get typed for sure

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @happygal321

1 Like

Thanks this worked!

Follow up question:

In my application I have some fields that are blank. I scraped it the same way as described above and save it into a variable. However, when I try CType(myString, Integer), i get an error: “Message: Conversion from “[–” to type ‘Integer’ is not valid.”

Is there a way to correct this? or how would i be able make the bot recognize that if the field is empty and save the variable as 0?


Use if condition as

IsNumeric(string) and in
Then --> convert using the above
Else --> valuestring = 0 using assign


1 Like