Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Removing a number variable of spaces at the start of a string

  1. #1

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Resolved [RESOLVED] [2005] Removing a number variable of spaces at the start of a string

    Hi!!!

    I want to remove in a string any spaces in the begining of the string, but the string can have a variable spaces at the start and also HAS spaces in the middle and in the end. So i just want to remove the "start spaces" not the other ones and these "start spaces" can be diferent. Sometimes can only be 2 spaces and sometimes can be 5 spaces. U get the pic.
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Removing a number variable of spaces at the start of a string

    Code:
    Dim MyString as String =  "     HELLO WORLD"
    MyString = MyString.TrimStart
    Messagebox.Show(MyString)

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: [2005] Removing a number variable of spaces at the start of a string

    Look at the Trim function and see if it will do what you want. I believe there is a variant to Trim from front, back, or both. If that is not sufficient, then you might have to walk along the string removing spaces, but Trim should suffice.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [2005] Removing a number variable of spaces at the start of a string

    Thks a lot!!! I didnt use that function earlier because it says:
    "Removes all occurrences of a set of characters specified in a array from the beginning of this instance" and it has a Parameter and no overloads. So i fought it couldn't be used without any parameters.
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [RESOLVED] [2005] Removing a number variable of spaces at the start of a string

    true, but if you look at the return value section of the MSDN doc for this function it states:

    The string that remains after all occurrences of characters in the trimChars parameter are removed from the start of the current String object. If trimChars is a null reference (Nothing in Visual Basic), white-space characters are removed instead.

  6. #6

    Thread Starter
    Fanatic Member Lasering's Avatar
    Join Date
    May 2006
    Location
    Lisboa
    Posts
    559

    Re: [RESOLVED] [2005] Removing a number variable of spaces at the start of a string

    lol. Looks like i have to read more in order to get more info. Because if i've read that i woudnt ask in the first place, lool
    Controls: XPCC|Quantum
    Windows API'sLINQ to XML SamplesRegex Tutorial

    Albert Einstein:
    "Imagination is more important than knowledge."
    "Everything should be made as simple as possible, but not simpler."
    "Great spirits have often encountered violent opposition from weak minds."

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