# Convert array string to integer

**URL:** <https://forum.uipath.com/t/convert-array-string-to-integer/483815>\
**Category:** Activities\
**Tags:** data-manipulation, question, system, activities\
**Created:** [October 24, 2022, 6:43am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815 "2022-10-24T06:43:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 6:43am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/1 "2022-10-24T06:43:44Z")

</div>

Hello.  
I am with an activity, in which I extract a text, cut it and obtain a number that I need to convert to integer format, to be able to compare it later, but I cannot convert it, since it is in an array.  
I show you the process.

 ![Captura de pantalla 2022-10-24 a las 8.33.53](https://global.discourse-cdn.com/uipath/original/4X/3/0/8/3083faa4124d159bbb4395a411eaafe87b4b901a.png)  
[Array\_int.xaml](https://forum.uipath.com/uploads/short-url/rSqc3cBbQNZskHmFlMGeEhT3bqB.xaml) (8,0 KB)

Example imagen:  
[Array\_int2.xaml](https://forum.uipath.com/uploads/short-url/55pXhe1Dco0Zu83C8fWQX5TYGr4.xaml) (7,4 KB)

---

<div class="post-metadata">

**Author:** ![Marius\_Puscasu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marius_puscasu/32/208478_2.png) [@Marius\_Puscasu](https://forum.uipath.com/u/Marius_Puscasu)\
**Post date:** [October 24, 2022, 6:47am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/2 "2022-10-24T06:47:48Z")

</div>

Hello @Aguirre ,

You might try an assign like this:

```auto
intArray = Array.ConvertAll(New_Text, Function(str) Int32.Parse(str))

```

Hope it helps!  
Best regards,  
Marius

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [October 24, 2022, 6:51am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/3 "2022-10-24T06:51:33Z")

</div>

Hi @Aguirre

You can try this

Cint(Trim(New\_text(1)))

Regards  
Sudharsan

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 6:52am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/4 "2022-10-24T06:52:56Z")

</div>

Hello, I have tried as you tell me, but it gives me an error, would it be like this?  
ERro:  
A value of type ‘-1 dimensional array of integer’ cannot be converted to integer

 ![Captura de pantalla 2022-10-24 a las 8.51.18](https://global.discourse-cdn.com/uipath/original/4X/0/5/a/05a46601d87c66ef0ed2ea101b6d9ef18313581f.png)

---

<div class="post-metadata">

**Author:** ![Marius\_Puscasu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marius_puscasu/32/208478_2.png) [@Marius\_Puscasu](https://forum.uipath.com/u/Marius_Puscasu)\
**Post date:** [October 24, 2022, 7:03am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/5 "2022-10-24T07:03:10Z")

</div>

@Aguirre

Please use `int.TryParse` instead of `Int32.Parse`.  
It seems that not all your data split by “:” can be an integer.

More info here: [https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-6.0](https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-6.0)

Best regards,  
Marius

---

<div class="post-metadata">

**Author:** ![ignasi.peiris](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ignasi.peiris/32/523526_2.png) [@ignasi.peiris](https://forum.uipath.com/u/ignasi.peiris)\
**Post date:** [October 24, 2022, 7:11am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/6 "2022-10-24T07:11:54Z")

</div>

you can try with LINQ, using Select:

Input = Array of strings (Result of the Split assign)  
Output = Array of Int32

```auto
var_arr_Strings.Select(function(x) CInt(x)).ToArray

```

![image](https://global.discourse-cdn.com/uipath/original/4X/9/f/f/9ff1199b518388c523c5dc2a70352621d4013b39.png)

![image](https://global.discourse-cdn.com/uipath/original/4X/1/c/6/1c6bd16725788e6986d7b7156e8476ab63e90ac1.png)

Edit:  
In case there is possibility of having strings in between, for example, taking this string as original input:

```auto
"1:2:3:4:10:50:50:abc"

```

You can add a .Where to the LINQ, to make sure it only returns the Int32 results.

- Simply change the code above, by this code:

```auto
var_arr_Strings.Where(function(y) IsNumeric(y)).Select(function(x) CInt(x)).ToArray

```

![image](https://global.discourse-cdn.com/uipath/original/4X/c/f/4/cf4d14b06e3ff55b28910d477db5d04e6b4dc721.png)

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 7:27am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/7 "2022-10-24T07:27:19Z")

</div>

Hello gives error:  
Option Strict does not allow the implicit conversion of integer in string

 ![Captura de pantalla 2022-10-24 a las 9.25.51](https://global.discourse-cdn.com/uipath/original/4X/a/c/6/ac6dd69ce7234872ed9a4f799727c21079ce0b8d.png)

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 7:34am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/8 "2022-10-24T07:34:37Z")

</div>

Hello.  
If that’s how I put it, it doesn’t work either.

 ![Captura de pantalla 2022-10-24 a las 9.33.59](https://global.discourse-cdn.com/uipath/original/4X/5/2/7/52795e8eba0f75bcb311b7480ece9997c40584b1.png)

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 7:47am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/9 "2022-10-24T07:47:53Z")

</div>

Hi, I think I’m not doing something right.  
ERROR:

Assign: Conversion from string “Number of items found” to type ‘Integer’ is not valid.

 ![Captura de pantalla 2022-10-24 a las 9.46.16](https://global.discourse-cdn.com/uipath/original/4X/9/2/2/922426cf4275947e61523212b01ac7f661a98e41.png)

---

<div class="post-metadata">

**Author:** ![ignasi.peiris](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ignasi.peiris/32/523526_2.png) [@ignasi.peiris](https://forum.uipath.com/u/ignasi.peiris)\
**Post date:** [October 24, 2022, 7:49am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/10 "2022-10-24T07:49:55Z")

</div>

Yep, one of the values is text, which contains the string: “Número de elementos encontrados”

- To avoid getting this error, please try to use the 2nd LINQ expression I posted:

```auto
var_arr_Strings.Where(function(y) IsNumeric(y)).Select(function(x) CInt(x)).ToArray

```

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 7:59am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/11 "2022-10-24T07:59:24Z")

</div>

I think I’m not putting something right, since it keeps giving an error and it’s a simple example.

“var\_arr\_Strings.Where(Function(y) IsNumeric(y)).Select(Function(x) CInt(x)).ToArray”.  
An instance member of a class cannot be referenced from a shared method or shared member initializer without an explicit instance of the class.

![Captura de pantalla 2022-10-24 a las 9.57.05](https://global.discourse-cdn.com/uipath/original/4X/c/3/2/c324a6d935b9624ac7ef81977eb2a244f300d701.png)

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 8:08am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/12 "2022-10-24T08:08:26Z")

</div>

Hello, I publish my example, to see if it is easier to find the solution  
[Array\_int.xaml](https://forum.uipath.com/uploads/short-url/rSqc3cBbQNZskHmFlMGeEhT3bqB.xaml) (8,0 KB)

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [October 24, 2022, 8:09am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/13 "2022-10-24T08:09:00Z")

</div>

> [@Aguirre](#):
>
> “var\_arr\_Strings.Where(Function(y) IsNumeric(y)).Select(Function(x) CInt(x)).ToArray”.  
> An instance member of a class cannot be referenced from a shared method or shared member initializer without an explicit instance of the class.

@Aguirre ,

At times, we would need to access `IsNumeric` method on the object, hence `IsNumeric(y)` should be changed to `y.IsNumeric` and Checked.

---

<div class="post-metadata">

**Author:** ![ignasi.peiris](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ignasi.peiris/32/523526_2.png) [@ignasi.peiris](https://forum.uipath.com/u/ignasi.peiris)\
**Post date:** [October 24, 2022, 8:13am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/14 "2022-10-24T08:13:32Z")

</div>

Please check the following 2 options:

Based on your input from images above, you could use regex to extract the number directly, without the need of arrays:

Option1: Arrays + LINQ  
[TestLinq.xaml](https://forum.uipath.com/uploads/short-url/1DE8ie8C5Ykmhcr3uPC3CRRBRI5.xaml) (6.6 KB)

Option2: Regex  
[Test\_Regex.xaml](https://forum.uipath.com/uploads/short-url/8N70rfRcRL76tfrVEl6aKseNcNk.xaml) (5.2 KB)

Regex solution in a nutshell:

![image](https://global.discourse-cdn.com/uipath/original/4X/1/b/2/1b2677b58a8f66f8fd600048a92d5e79df127a81.png)

out\_ExtractedValue = System.Text.RegularExpressions.Regex.Matches(var\_initString,“\d”)(0).ToString

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 8:25am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/15 "2022-10-24T08:25:47Z")

</div>

When comparing the obtained value it does not do it correctly.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/b/5/3b5c4f3387647fa2b54409eaf1c89bccee1ed15b.png)

---

<div class="post-metadata">

**Author:** ![Areej\_fatima](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/areej_fatima/32/556811_2.png) [@Areej\_fatima](https://forum.uipath.com/u/Areej_fatima)\
**Post date:** [October 24, 2022, 8:27am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/16 "2022-10-24T08:27:04Z")

</div>

Use this in assign  
`IntArr = StrArr.Select(Function (p) cint(p)).toArray`

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 8:29am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/17 "2022-10-24T08:29:31Z")

</div>

The LINQ solution gives an error before executing it, without touching anything.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/6/a/76a72d963384f527aeae86c318a72215c38e36e2.png)

---

<div class="post-metadata">

**Author:** ![ignasi.peiris](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ignasi.peiris/32/523526_2.png) [@ignasi.peiris](https://forum.uipath.com/u/ignasi.peiris)\
**Post date:** [October 24, 2022, 8:30am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/18 "2022-10-24T08:30:14Z")

</div>

out\_extractedValue on the examples I sent, was of type string, and you can’t compare “9”\<“10” with strings

Try This:

on the if: CInt(out\_ExtractedValue) \> 10

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 8:34am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/19 "2022-10-24T08:34:55Z")

</div>

Hello, would it be as you say?  
it gives me an error.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/1/9/b19b5a76d863d15e3e7ffb33cca3bba2ca795348.png)

---

<div class="post-metadata">

**Author:** ![Aguirre](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aguirre/32/221875_2.png) [@Aguirre](https://forum.uipath.com/u/Aguirre)\
**Post date:** [October 24, 2022, 8:37am UTC](https://forum.uipath.com/t/convert-array-string-to-integer/483815/20 "2022-10-24T08:37:55Z")

</div>

I given:  
"CInt(out\_ExtractedValue) \>“10"”.  
Option Strict On does not allow implicit conversion of ‘String’ to

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/1/2/e124b25f68e6a2c1bf2d1289fc968871cfbe97ea.png)

[Next page](https://forum.uipath.com/t/convert-array-string-to-integer/483815.md?page=2)
