Integer to array conversion


I am trying to convert a string to integer and trying to save it in an array of integers.

Pages = Integer.Parse(page_count.Substring(7,2))

Note: Pages should be of type Int32.
I am getting an error as a value of type integer cannot be converted to a 1-dimensional array.

Can anyone please help me to figure this out.

Hi Sarigam,

You need to do the following steps, right?
String → Integer
Integer → one value of Int32

If so, please refer to the prototype of this solution

Hope this helps!

1 Like


It was throwing error because Integer.Parse(page_count.Substring(7,2)) returns a Integer value.
But Pages is an array variable. So the place where the integer has to be stored must be mentioned like Pages(0) or Pages(i) where i can be declared as a counter variable.


Hi @Sarigam,

Alongwith the clear and detailed explanation from SaranyaKishore, We can also use a one line conversion.


String Page_count = "123456"

Code Snippet:

int[] intArray = Page_count.Substring(1,2).Select(Function(x) Val(x)).ToArray()


Getting two chars as a string and selecting the individual characters of string i.e here 2 and 3 & using Microsoft.VisualBasic.Val to get only the values and parse as integers
Microsoft.VisualBasic.Asc to get only the ASCII values and parse as integers

Dom :slight_smile:

1 Like

Thank you for your prompt response.

Let me explain more detail on it.
String Page_count = “24 items in 3 pages”

I have to store the value “3” to variable type of integer array Pages in the above string.

then I have to use the Pages in For each activity

I tried the above example and still am not getting the desired output.

Sariga, Let me confirm my understanding !

String Page_count = “24 items in 3 pages”
  1. From the above string, Do you want to extract 3 alone ? or all the numbers 24 and 3 ?
  2. Do you want to loop that many number of times ? (Here 3 times)

Just to extract 3 alone.
Yes, I want to loop that many number of times

1 Like

Hi @sarigam,
You I have attached the source for the page loop. it helps you.

File : (2.2 KB)


1 Like

Thank you Balamurugan.
I need to use For each Activity not the do while for some reasons

1 Like

Hi @sarigam,
I did the changes now. It will have the loop by for.

File : (2.3 KB)


I tried the same. But receving error as Input string is not in correct format

Hi @sarigam,
Did you get error in my sample project ? or the implemented one ?


On the implemented one…

Hi @sarigam,
Can you check the variable declarations.

The for loop activity should be like this