Results 1 to 4 of 4

Thread: strings

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    strings

    I have been sitting here for 2 hours trying to figure out this ##!!?!?!? problem

    I am VERY VERY stressed and annoyed

    I was to retrieve the last character of this string "]2"

    HOW do I do it? everytime I do it, I either get an exception or I get the same string returned back to me

    string test = data.Substring(data.LastIndexOf("]", data.LastIndexOf("]"), 1));

    ?!?!?!?!?!!?

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: strings

    No need to put the length of the character since you're getting the last character

    you could do substring such as this one

    string test = data.substring(data.length -1).tostring()

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

    Re: strings

    If you want the last character of a string then do as mar_zim says, although you don't need the call to ToString at the end because Substring returns a String object already. If you want all the characters after the last occurrence of "]" regardless how many characters that is, us this:
    Code:
    string test = data.Substring(data.LastIndexOf(']') + 1);
    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

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: strings

    URGH... completly forgot about it

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