I am getting an error to convert to integer from string


I am getting this in the if condition loop to convert into a ineger form

1 Like

Hi

Welcome to UiPath forum

If that column of index 0 is already a integer then try directly mentioning like this

CurrentRow(0) < 100

Or

If that doesn’t work try like this

Convert.Toint32(CurrentRow(0).ToString)<100

Cheers @khantil_desai

HI,

I guess you use ForEachExcelRow activity. If so, can you try the following exprression?

CInt(CurrentRow.ByIndex(0).ToString)<100

OR, if HasHeader option is enabled, the following will also work.

CInt(CurrentRow("ColumnName").ToString)<100

Regards,

Hi,

The error message you’re encountering, Disallows implicit conversions from integer to string, is because you are trying to compare an integer to a string without converting the integer to a string explicitly. To fix this issue, you need to convert the integer to a string before making the comparison. You can do this by using the ToString method to convert the integer to a string. Here’s how you can modify your expression:

CInt(currentrow(0).ToString) < 100

In this modified expression, currentrow(0).ToString first converts the value in the first column of the current row to a string, and then CInt converts it back to an integer for comparison. This ensures that both sides of the comparison are of the same data type, which resolves the error.