Results 1 to 4 of 4

Thread: String Manipulation (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    312

    String Manipulation (Resolved)

    How to get the Characters between two given integers.
    For example i have a String "I am ,learning, Vb.net", now i want to get the word "learning" out of this string.

    Want command should i use.Remember that there are two commas in the String.
    Last edited by Raziiq; Apr 27th, 2005 at 02:31 PM.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: String Manipulation

    Your example seems off - it doesn't contain any integers.

    VB Code:
    1. Dim temp As String = "I am, learning, vb.net"
    2. Dim extraction As String = temp.Substring(temp.IndexOf("learning"),"learning".Length)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    312

    Re: String Manipulation

    ok that was great
    But what if i have "i have ,2036, pages in this book"
    Now if the integer 2036 is different everytime then how to get that 2036 from this string.
    For example at first time it is 2036 and if i click button again and then the String is "i have ,480661, pages in this book". how to get this integer out from this string.

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: String Manipulation

    VB Code:
    1. 'vb
    2. Dim temp As String = "this is me learning, 2036, pages of .Net";
    3.             Dim startIndex As Integer = temp.IndexOf(",") + 1;
    4.             Dim endIndex As Integer = temp.IndexOf(",",startIndex);
    5.             Dim extraction As String = temp.Substring(startIndex,endIndex-startIndex).Trim;
    6.  
    7. 'c#
    8. int startIndex = temp.IndexOf(",") + 1;
    9.             int endIndex = temp.IndexOf(",",startIndex);
    10.             string r = temp.Substring(startIndex,endIndex-startIndex).Trim();

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