String Manipulation - Help

Hi, Can anyone help me into this, I used Get text data and it is returning the String Value and i splitted that by using , Wholedata.Split(Environment.NewLine.ToArray)(4) but sometime there is no data present in this, So it is throwing error like, Index out of Range.

But what i want, if data is not present simply it left that Blank and move ahead with next transaction.
Can anyone help me , How can i overcome from this error.
Thank you in Advance.

I assume your string variable name is Wholedata.

You can use an if condition like this:
if((Wholedata isNot Nothing) And (Wholedata.trim() <> “”))
{
ArrayVar1 = Wholedata.Split(Environment.NewLine.ToArray)
if(ArrayVar1.length > 4)
{
FinalStringVariable = ArrayVar1(4)
}
}

This way you can check if your variable is not null. As(in this code) you are checking for array(after splitting string) length and then accessing it’s element, there won’t be any IndexOutOfRange exceptions

1 Like

HI @Anjali_Rani

Frim what @Surya_Narayana_Korivipadu said, i am assuming you put an assign activity for storing the Wholedata.Split(Environment.NewLine.ToArray)(4), use try catch activity and put the assign inside the try block.

Thanks

1 Like

Thank you :slightly_smiling_face:

Thank you :+1:

1 Like

Did it help you to solve your problem? If yes, can you please mark it as solution

1 Like