This function can be used to return only the characters and numbers in any string. It is useful for string comparison and data comparison. All spaces and other special characters will be removed from the return value.
Public Function ReturnOnlyCharactersandNumbers(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 span="" then="">91>
mystr = mystr & Chr(sASCII)
Elseif sASCII >96 and sASCII < 123 Then
mystr = mystr & Chr(sASCII)
Elseif IsNumeric(sChar) = True Then
mystr = mystr & sChar
End If
Next
ReturnOnlyCharactersandNumbers = Ucase(mystr)
End Function
Public Function ReturnOnlyCharactersandNumbers(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 span="" then="">91>
mystr = mystr & Chr(sASCII)
Elseif sASCII >96 and sASCII < 123 Then
mystr = mystr & Chr(sASCII)
Elseif IsNumeric(sChar) = True Then
mystr = mystr & sChar
End If
Next
ReturnOnlyCharactersandNumbers = Ucase(mystr)
End Function
No comments:
Post a Comment