Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2002
    Posts
    9

    Unanswered: Remove Spaces From String

    Hi,

    I think I have seen a posting regarding this but I can't find it.

    I want to be able to remove spaces from a string ie:

    DN12 8BR to DN128BR

    Can anyone remember how to do this?

    Thanks in advance

    Darrell.....

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Darrell
    Hi,

    I think I have seen a posting regarding this but I can't find it.

    I want to be able to remove spaces from a string ie:

    DN12 8BR to DN128BR

    Can anyone remember how to do this?

    Thanks in advance

    Darrell.....
    Use the Replace function ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by M Owen
    Use the Replace function ...
    haha, you're such a tease.

    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    May I ask what character will replace "".
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by r123456
    May I ask what character will replace "".
    you answered your own question.

    " " <> ""
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Post

    Here is a function to remove any spaces from any text

    PHP Code:
     Function TrimAll(thisString As StringthisSeparator As String) As String
       Dim sepPosition 
    As IntegerlastPosition As Integer
       Dim j 
    As IntegerAs IntegerAs Integertrimmed As String
       s 
    11trimmed ""
      
    Do
        
    sepPosition InStr(jthisStringthisSeparator)
        If 
    sepPosition 0 Then
           lastPosition 
    j
           j 
    sepPosition 1
        
    Else
           
    sepPosition 1
           trimmed 
    trimmed Mid$(thisStringssepPosition s)
           
    j
        End 
    If
      
    Loop While <> 1
      TrimAll 
    trimmed Mid$(thisStringlastPosition100)   ' the last word
      End Function 
    Usage

    TrimAll ("Hello World Today Morning ", " ")

    Returns
    HelloWorldTodayMorning

    Have fun

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You can use also the Trim function to remove leading and trailing spaces just have a look to
    LTrim, RTrim and Trim functions

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Why re-invent the wheel hamm? Seems like an awful lot of work to duplicate an already built-in function.

    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Talking

    Quote Originally Posted by Teddy
    Why re-invent the wheel hamm? Seems like an awful lot of work to duplicate an already built-in function.

    And what is that built in function to remove the inner spaces of a string?

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by hammbakka
    And what is that built in function to remove the inner spaces of a string?

    *sigh*

    So much for encouraging lateral thinking.

    REPLACE([field], " ", "")
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You are lucky to use Acce$$ 2000, but I use Acce$$97, so that I had to write my own function. There is no Replace function in Acce$$97

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •