Results 1 to 3 of 3

Thread: String manipulation tips anyone?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    143

    String manipulation tips anyone?

    What is possible through string manipulation... any tips someone could give for a person who really hasn't done much with strings (besides stick them together and assign new values to them)? Perhaps a halpful tutorial?

    I need to locate a string in a rich text box, then assign it and the 32 characters that follow it to it's own string. Tips/Codes anyone?

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

    Re: String manipulation tips anyone?

    The first thing to do is take a look at the MSDN help topic for the String class and see what members it has and what each can do.
    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
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: String manipulation tips anyone?

    Using String.IndexOf and String.Substring...
    VB Code:
    1. Dim TestString As String = "blah blah test12345678901234567890123456789012end"
    2.         Dim SearchString As String = "test"
    3.         Dim Result As Integer = TestString.IndexOf(SearchString, 0)
    4.         If Result >= 0 Then
    5.             MessageBox.Show(TestString.Substring(Result, SearchString.Length + 32))
    6.         End If
    Using Regex...
    VB Code:
    1. Dim TestString As String = "blah blah test12345678901234567890123456789012end"
    2.         Dim SearchString As String = "test"
    3.         Dim RegexPattern As String = SearchString & ".{32}"
    4.         Dim MyMatches As System.Text.RegularExpressions.MatchCollection = _
    5.             System.Text.RegularExpressions.Regex.Matches(TestString, RegexPattern)
    6.         For Each Match As System.Text.RegularExpressions.Match In MyMatches
    7.             MessageBox.Show(Match.Value)
    8.         Next
    Last edited by gigemboy; Jan 18th, 2007 at 09:15 AM.

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