Convert int to string

Hello i have a function where a variable1 its stored. I am then using “Excel application Scope” to match this Variable1 up with a excel sheet to transform the Variable1 into another value. Currently I am assigned the ouput value to another Variable because i get an error if i assign variable1. The problem its that UIPATH thinks the output its a integer and i need it to be a String. My question its. How can i Convert a integer/double output to a string

You can simply convert the integer as string using

CType(variable, string)

But I don’t your requirement above

1 Like

Its not exaclty what i want
I want to use the same variable for input and output

Fine

Then in that case create that variable1 as a GENERIC datatype variable so that it can store both string and int32 value

Cheers @langsem

It has to be a string everytime

Can you put here the expression you are trying to write? What is the error that is coming up?

Fine
then wherever needed we can mention as VariableName.ToString
and if we want to be the variable as a string datatype always and meanwhile if we want to assign that to a int32 variable then use Convert.ToInt32(“VariableName”)

Cheers @langsem

Fine
where you would like to make the conversion here
kindly elaborate the scenario pls
Cheers @langsem

so i have a variable storing branch. and in the excel app scope i am looking at a list to match var with a var from that list and convert it into a another var, but the list contains a integer as output and want to retreive a sting

Hi @langsem,

If you just want to convert an ‘integer’ variable to ‘string’, please try -
variable1.ToString
Considered that ‘variable1’ is your variable.

Thanks & Regards,
Apurba

Just create a second variable (of type string). Then you can use an assign to convert it to string: Assign SecondVariable = FirstVariable.ToString

I wouldn’t try to make things too complicated, this makes it very clear what is happening to anyone else reviewing your code

1 Like

so as suggested earlier if we are trying to access the value from list with its index like this

listvariablename(0).ToString

Cheers @langsem

Gives me error invalid-L

Dear,

Can you please send me the screenshot of the error for better understanding?

Thanks & Regards,
Apurba

says invalid-L value expression

U GOT THE ANSWER?

Hi can we convert int to string? I want to assign integer value x but when I m selecting variable type int32 then it’s not taking