|
-
Nov 3rd, 2005, 02:36 AM
#1
Thread Starter
Member
[RESOLVED]Trimming a string question
How would I trim a string that has a length greater than 6 characters? I've searched the forums but haven't found what I am looking for yet... any help would be appreciated!
Thanks!
Last edited by infinisource; Nov 3rd, 2005 at 03:40 AM.
-
Nov 3rd, 2005, 02:47 AM
#2
Re: Trimming a string question
The Length of a String has no bearing on the Trim, TrimStart and TrimEnd methods. They will remove all occurrences of a character or characters from the start, end or both of a String. If you mean how can you get just the first six characters then you would use the Substring method:
VB Code:
Dim newString As String = oldString.Substring(0, Math.Min(6, oldString.Length))
-
Nov 3rd, 2005, 03:39 AM
#3
Thread Starter
Member
Re: Trimming a string question
 Originally Posted by jmcilhinney
The Length of a String has no bearing on the Trim, TrimStart and TrimEnd methods. They will remove all occurrences of a character or characters from the start, end or both of a String. If you mean how can you get just the first six characters then you would use the Substring method:
VB Code:
Dim newString As String = oldString.Substring(0, Math.Min(6, oldString.Length))
thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|