Can’t figure out why this won’t work.
I am trying to analyse a string of variable length containing a “.” somewhere inside, and then strip off the “.” and all characters before it. This is called via a web service.
When debugging, it works fine until it bails out at the last line, below, with the browser message:
“System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
“
Anyone got any idea?
Code1, below, is an input variable passed to the web service from an eform.
Dim CharNo As New Integer
CharNo = Code1.IndexOf(".")
MyCodebookValueStrip.o_Code1 = Code1.Substring(CharNo + 1, (Code1.Length - CharNo))
Your calculation of the lenth of the remaining string is incorrect. You have to subtract one more:
You can also just omit the second parameter, and it will get the rest of the string: