I’m trying to give a condition in which I am checking if the datatable row is 0 or empty in an excel.
But I’m getting the error If: Conversion from string “” to type ‘Integer’ is not valid. as in below picture.
String.IsNullorEmpty(DT_Product.Rows(0)(0).Tostring) Or CInt(DT_Product.Rows(0)(“Actual”).ToString).Tostring= 0 or DT_Product.Rows(0)(“Actual”).ToString = “”
value is blank so the CInt fails
give a try at following
isNothing(DT_Product.Rows(0)(“Actual”) OrElse String.IsNullOrEmpty(DT_Product.Rows(0)(“Actual”).ToString.Trim) OrElse cint(DT_Product.Rows(0)(“Actual”).ToString)= 0
What this does is looks at the first part and if it’s true it doesn’t bother even processing the second one, so the conversion to INT won’t be tried on an empty string. If the first is false, meaning the string is not empty, only then is the second expression processed.