Replace All Letters

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.
 
B

Bob Barrows

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top