Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 21,749 times

Related Categories

Strip Spaces from String - Strip Spaces from String

Andrew Yap

Strip Spaces from String

Usually this function helps a lot in data cleansing.

Call the function FnCleanString with a string values and it will reformat and pass back a string with all the spaces removed.

You can modify this code to cater for other scenarios, say stripping numeric characters or stripping non alphabets from string.

Usefulness is very much on how creative you can apply this function. Have fun.
:)


Function FnCleanString(pString As String) As String
Dim tString As String
Dim tLength As Integer
Dim lCtr As Integer
   tString = ""
   tLength = Len(pString)
   For lCtr = 1 To tLength
       If Mid(pString, lCtr, 1) <> " " Then
          tString = tString & Mid(pString, lCtr, 1)
       End If
   Next lCtr
   FnCleanString = tString
End Function

Comments

  • Re: Replace

    Posted by sudhakarsvr2000 on 06 Feb 2008

    Hi,


    I urgent help.


    I have a string like " where are you,"can you help me" please." So I need to remove the quotes " " in between quot...

  • Replace

    Posted by dankan on 06 Jun 2003

    Try the replace Function
    Replace(StringGoesHere," ","")