Index Was Outside of the bounds of the string Array

here in the image attached , i am dynamically adding a string to the string array and this error pops up. can someone help.
1.intLoop is the counter and starts with 0 .
2. when am assigining directly the error does not pop up like ( strArrayName(0) = "hi)
but this error pops up when i write code like
strArrayName(intLoop) = string

1 Like

Yes @Nandhini_Vishnu

Because you haven’t mentioned your array size.

If you are not sure on the size of the collection, best is to go with list !

1 Like

Hello @Nandhini_Vishnu

In you case List is the best option than array. if you are still going to use array then you need to initialise the size of the array. Otherwise you will get the the outside of bounds error.

1 Like

@Nandhini_Vishnu 10 represents the count which defines maximum number of sub strings to return. That means when it is returning the value it is trying to store these 10 sub strings in different array index (Ex: Arr[0] = FirstSubString, Arr[1] = Second Substring etc). But you were trying to assign all these in an array of index 0. That could cause the issue. try the below one and share the results

Remove intLoop then exp should be

strArrayName=Split(strName, " ")(10)

See if it giving the same exception this case


thanks , its working .

thanks a ton.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.