substring

Signo.X

Well-known member
Joined
Aug 21, 2006
Messages
76
Location
Australia
Programming Experience
1-3
dim s as string = "123456"

is there any way where i can specify the start and end index of the string to be displayed?

for example .. if i use s.substring(0,3) will display the chars 1 2 3, but how can i do the same thing by specifying a start and end index of the string to be displayed...

thanks

signo.x
 
length = endindex - startindex
s.substring(startindex,length)
 
By saying s.Substring(0,3) you are specifiying the start and end index of the string to be displayed. Do you mean the start and in digit/charactor?
 
By saying s.Substring(0,3) you are specifiying the start and end index of the string to be displayed.
No, you're not - you're specifying startindex and length.
 
Ah! I knew I had to be misreading something there. Thanks for pointing it out for me!

doesnt that work out at the end to be the same thing ?

- the start index will always be the same .
- the end index(the length i.e. the size from the start till the end)


do you agree ??
it's a bit confusing but in my case it worked exactely the same!!!
 
for Java: substring(StartIndex, EndIndex)
for VB.Net: SubString(StartIndex, Length)

so to get Java's substring to work like VB.Net's SubString:
VB.NET:
private static String SubString(String source, int start, int length)
{
    return source.substring(start, (start + length));
}
 
Back
Top