Results 1 to 3 of 3

Thread: [RESOLVED]Trimming a string question

  1. #1

    Thread Starter
    Member infinisource's Avatar
    Join Date
    Oct 2005
    Location
    Lee's Summit, MO
    Posts
    60

    [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Dim newString As String = oldString.Substring(0, Math.Min(6, oldString.Length))
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member infinisource's Avatar
    Join Date
    Oct 2005
    Location
    Lee's Summit, MO
    Posts
    60

    Re: Trimming a string question

    Quote 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:
    1. 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
  •  



Click Here to Expand Forum to Full Width