Replace All Letters

  • Thread starter Thread starter lindag
  • Start date Start date
L

lindag

Is there a way to use the replace function to replace all letters?

I have tried several different ways. I am looking to do something
like this: Replace([COMMENT],"[a-z]","").

Thank you.
 
lindag said:
Is there a way to use the replace function to replace all letters?

I have tried several different ways. I am looking to do something
like this: Replace([COMMENT],"[a-z]","").

Thank you.
My initial reaction was:
Set [COMMENT] = ""
But then i realized you intended to leave numeric and punctuation characters
in place.
So the answer is: you will have to write a function to do that. My first
thought would be to use a loop:

Function ReplaceLetters (s as string) as string
'the ascii code for "a" is 97, and "z" 122. so:
dim i as integer
for i=97 to 122
s=Replace(s,chr(i),"")
next i
ReplaceLetters=s
End Function
 
Back
Top