Search This Blog

Monday, February 11, 2013

Function to return only characters in any string

This function can be used to return only the characters in any string. It is useful for string comparison and data comparison. All spaces and other characters will be removed from the return value.



Public Function ReturnOnlyCharacters (myString)
mystr = NULL
sLen = Len(myString)
snewLen = sLen
For i = 1 to sLen
sChar = Left(myString,1)
sASCII= Asc(sChar)
myString = Right(myString,(snewLen-1))
snewLen = Len(myString)
If sASCII >64 and sASCII <91 p="" then=""> mystr = mystr & Chr(sASCII)
End If
If sASCII >96 and sASCII < 123 Then
mystr = mystr & Chr(sASCII)
End If
Next
ReturnOnlyCharacters = Ucase(mystr)
End Function

No comments:

Post a Comment