Conversion from INT to String

I’m trying to convert int row to string in excel


1 Like


Are you trying to convert String to interger right ?

Are you facing any issue here ?

Convert.ToInt32(row(2).ToString) try this buddy @Loka625
the one you are using is find buddy

Yes, I’m trying to convert column Row with integers to string, but i’m getting this errorCapture1

Buddy does that row has empty string or null in it @Loka625
or any space in between the strings or at last with spaces
if so use like this buddy cint(row(3).ToString.Trim) @Loka625

It says input string is not in correct format

Buddy may i know where that row comes from whether a for each row loop or for each loop

Cheers @Loka625

for each row loop

data is read from excel, used for each row loop, to loop through all the columns in excel, one of those columns is Row column with integer values

1 Like

try this alone buddy, this should work actually as you are going good

yah got it buddy @Loka625 , actually the problem occurs when the assignment meets this row
and it has empty value in it, so while trying to convert that as integer we were geting error like string " " cannot be converted to integer
So in that just use a validation before assigning in_Rownumber with a if condition like this

  1. if condition like this
    Not String.IsNullOrEmpty(row(3))
    if this condition passes, in then part of if condition assign like how you do now
    else assign with
    in_Rownumber = 0

Thats all buddy you are done. Kindly try and let know buddy @Loka625

Cheers @Loka625

Did that work buddy @Loka625

I will test it and let you know, thanks

1 Like

Hey @Palaniyappan and @Loka625

You can use

Int32 var;
boolean Success_or_not = Int32.TryParse(" ",var);
Writeline - var.ToString(); // 0  

Int32.TryParse() method returns if the conversion succeeded, contains the 32-bit signed integer value equivalent of the number contained in a string or zero if the conversion failed. The conversion fails if the s parameter is null or Empty.