Assign Activity - Split() - Index was outside the bounds of the array

I am iterating through a spreadsheet column that generally has a first and last name that I am trying to split into two columns.

Generally it works like a charm until I get to a cell that has “Steve/Suzie” with no space or last name.

Assign: strLastName = Split(strFirstName," ")(1)

I am reading the strFirstName string then splitting it into the strLastName with the above statement.

My problem is, when I have “Steve/Suzie” in the strFirstName field, the above statement doesn’t work because it is looking for what is AFTER the first space. In the “Steve/Suzie” cases, there is no space and I get the outside the bounds of the array error.

Essentially, I am trying to work around it by reading the string, if there’s no space, then move on. Or if there is no space the strLastName = “”

Any help or suggestions would be greatly appreciated.

Happy New Year!

Give a try in Working With

Lastname = strTextVar.split(" "c).skip(1).take(1)

Got an error.

Main.xaml: Cannot assign from type ‘System.Collections.Generic.IEnumerable’1[SystemString]’ to type ‘System.String’ in Assign activity ‘Assign’.

Per your guidance above I changed: strLastName = Split(strFirstName," ")(1)

strLastName = strFirstName.split(" "c).skip(1).take(1)

Ideas?

I threw a Try/Catch around it as it is infrequent and that solved it. Thanks.

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