Results 1 to 14 of 14

Thread: Replacing a " " with nothing

  1. #1

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Replacing a " " with nothing

    Well in some of the data im getting back, it has alot of spaces infront of it. It looks something like:

    " Data"

    I just want "Data", what would I replace to make it so it only contains "Data"? At first I thought it would be something like

    NewData = Replace(Data," ", VbNullstring)

    but that does not work like I thought it would. Any idea?

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Replacing a " " with nothing

    that should work 100%, try trim though
    trim(data)

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Replacing a " " with nothing

    Trim$, LTrim$, RTrim$

    Trim$ removes spaces from the left and right of the string, LTrim$ only from the left and RTrim$ only from the right


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Replacing a " " with nothing

    Do LTrim and RTrim run faster?

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Replacing a " " with nothing

    No clue, but if I had to guess I would say yes since Trim probably calls both... But if it doesn't actually trim one of the two (right-left) it won't affect it much? Just guessing trying to see what makes sense...


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Replacing a " " with nothing

    Unless you are doing some crazy amount of trims in a row I don't think that you would notice any difference
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Replacing a " " with nothing

    Trim$ is faster than Trim because it doesn't have to be converted to a string.

  8. #8

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Replacing a " " with nothing

    Okay, didn't know about the Trim command

    Anyways, since I dont really know it, im assuming it works the same as Replace in a way. I tried:

    OppName1 = LTrim$(OppName)
    Msgbox OppName1

    The spaces were still there. Am I using it wrong?

  9. #9
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Replacing a " " with nothing

    Try Trim$ and see what happens, not LTrim$

  10. #10
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Replacing a " " with nothing

    Where is the data from? It's a long shot for it not to work, but there is another space (that I don't remember it's name) character code 160, that Trim won't work with...


    Has someone helped you? Then you can Rate their helpful post.

  11. #11
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Replacing a " " with nothing

    Unless he makes his own unique Trim$ statement. Could come in handy if done right.

  12. #12
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Replacing a " " with nothing

    And I always thought this function I created would be useless

    This will remove the repetative first character calling it this way, whatever it is :

    VB Code:
    1. MsgBox ATrim(S, Mid$(S, 1, 1), False)


    Has someone helped you? Then you can Rate their helpful post.

  13. #13

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Replacing a " " with nothing

    *Edit* let me try it out.

  14. #14
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Replacing a " " with nothing

    If it always just a single space, you can use Mid$: String = Mid$(Text, 2)

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