Library code snippets
Strip Spaces from String
By Andrew Yap, published on 14 Jul 2001
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
Related articles
Related discussion
-
Run-time error '91'
by crazyidane (0 replies)
-
Problem handling Redirects with MSXML2.XMLHTTP
by brandoncampbell (2 replies)
-
vbinputbox pauses code while it waits on response. How can I reproduce that?
by brandoncampbell (1 replies)
-
Sending SMS in VB 6
by sirobnole (6 replies)
-
Comboxbox listindex in ActiveX Control
by brandoncampbell (1 replies)
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 quotes. Any one can help in this.
I need the string should be like this " Where are you,can you help me please".
I need to remove the quotes between middle of the string.
Its urgent help....
Thanks in advance..
Try the replace Function
Replace(StringGoesHere," ","")
This thread is for discussions of Strip Spaces from String.