A simple routine to remove all non-alphanumeric charaters from a string (Quickly!).
A simple routine to remove all non-alphanumeric charaters from a string (Quickly!).
Rate A simple routine to remove all non-alphanumeric charaters from a string (Quickly!).
(2(2 Vote))
'*****************************************************************
'Description: This routine will remove any non-alphanumeric
' characters from the Words.
'Pass: Words - Keywords to clean
'Return: CleanWords - Final clean string
'Raise Errors:
'-----------------------------------------------------------------
'Date Devoloper Comments
'9/1/00 R. Robinson Initial Design
'
'*****************************************************************
Const ALPHA = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
Const SNG_SPACE = " "
Const DBL_SPACE = " "
Dim iPos As Integer
Dim sChar As String, sWork As String
Dim lCntr As Long
'Set the working variable
sWork = Trim(Words)
'Remove all charaters that are NOT in the ALPHA const
For lCntr = 0 To 255
If InStr(ALPHA, Chr(lCntr)) = 0 Then
sWork = Replace(sWork, Chr(lCntr), SNG_SPACE)
End If
Next lCntr
'Remove all double spaces created
iPos = InStr(sWork, DBL_SPACE)
While iPos > 0
sWork = Replace(sWork, DBL_SPACE, SNG_SPACE)
iPos = InStr(sWork, DBL_SPACE)
Wend
'Return the cleaned string
CleanWords = sWork
End Function
A simple routine to remove all non-alphanumeric charaters from a string (Quickly!). Comments
No comments yet — be the first to post one!
Post a Comment