Split Long String by Character Place

RadioRaiders

Member
Joined
Oct 28, 2008
Messages
6
Programming Experience
Beginner
I have a String with 15 places that I would like to split into 3 pieces: (First 3 digits), (next 3 digits), (remaining 9 digits).

How in VB2008 can I do that? Everything I have read so far indicates seperating by a certain character (ie: "," or " ") but no mention of character place.:confused: Seems like a simple thing, but after 2 hours of searching I'm still coming up empty :eek:
 
Use the Substring method of the String where you specify the index to start and length of capture. See help for more explanations and code samples: String Members (System)
 
Use the Substring method of the String where you specify the index to start and length of capture. See help for more explanations and code samples: String Members (System)

Thanks! :) I was barking up the wrong tree with the "split". Should have been looking at the "substring". Thanks for pointing me in the right direction. Learing can be a b!tch sometimes ;)

dim test as string
test="123456789"
Dim MNC As String = test.Substring(3, 3)

returns "456"
 
firstThree = myString.Remove(3);
midThree = myString.Substring(3, 3);
lastNine = myString.Substring(myString.Length - 9);

Remove(length) is like LEFT
Substring(index, length) is like MID
Substring(stringLength - length) is like RIGHT
 
Back
Top