Removing anything not a letter or number in a string of text:
Return to List
Public Function EliminateWhitespace(ByVal strString As String) As String
' To replace all occurrences of one string in another ' Load every incoming character into an array Dim MyCharArray()
For i = 1 To Len(strString)
ReDim Preserve MyCharArray(i)
MyCharArray(i) = Mid(strString, i, 1)
Next
' Scan the array and eliminate anything not an alpha or numeric character For i = 1 To UBound(MyCharArray())
If MyCharArray(i) Like "[!0-9A-Za-z]" Then
MyCharArray(i) = ""
End If
Next
' Build the output string Dim strTemp As String
For i = 1 To UBound(MyCharArray())
If Len(MyCharArray(i)) > 0 Then
strTemp = strTemp & MyCharArray(i)
End If
Next
' Exit the function EliminateWhitespace = strTemp
End Function