Error : If: startIndex cannot be larger than length of string. (Parameter 'startIndex')

Hello everyone,

I am getting this error suddenly from yesterday onwards.
Error : If: startIndex cannot be larger than length of string. (Parameter ‘startIndex’)

How can I resolve this? before resolving I want to know why this error arrived? what’s the reason ?

Screenshot :


Hi @prabin_chand1

Looks like you are trying to perform a substring larger than lenght of your string, please check your value and count the characters there

Regards

@prabin_chand1

Are you using any list or anything in the condition or using substring?

It says the start indexyou provided is more than the total values present or the length of the string

Cheers

HI,

Can you try the following condition?

CardNumber.StartsWith("405019") AndAlso CardNumber.Length>=6 AndAlso not CardNumber.Substring(6).Contains("0000")

Regards,

1 Like

What’s the difference between And & AndAlso.?

Hi,

Andalso is short-circuiting operator. if the first condition is False, the following condition won’t be evaluated. (And operator always evaluates both conditions. It might be caused exception)
Please see the following document in details.

Regards,

1 Like

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