punctuation chars from a string. Suggested code was posted
using Replace function. Could the FN below be easily modified
for use with A97 which has no replace FN?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx
lucason
View profile
More options Aug 20 2003, 5:52 am
Newsgroups: comp.databases.ms-access
From: luca...@hotmail.com (lucason)
Date: 20 Aug 2003 02:52:36 -0700
Local: Wed, Aug 20 2003 5:52 am
Subject: Re: Remove Specific Characters From A text box
Reply to author | Forward | Print | Individual message | Show original
| Report this message | Find messages by this author
csgraha...@hotmail.com (Colin Graham) wrote in message
<news:ee**************************@posting.google. com>...
I need to write a function to remove any sort of punctuation from aYou didn't look very far before asking the question did you....
text box and only allow the characters from A to Z. E.g. If i type in
"Róisín" then i want the system not to allow this, even better if it
could change it to "Roisin" or if possible to remove any character
which isnt between A to Z. i am a bit stuck with this. Can anyone
please help????
Use the replace command!
Put it in a function if you like:
'StartCode-----------------------
Public Function FixString(strStringToChange As String) As String
Dim x As Integer
For x = 1 To Asc("A")
strStringToChange = Replace(strStringToChange, Chr(x), "")
Next x
For x = Asc("z") To 255
strStringToChange = Replace(strStringToChange, Chr(x), "")
Next x
FixString = strStringToChange
End Function
'-------------------------EndCode
If you like, you can add specific replacements:
'StartCode2-----------------------
Public Function FixString(strStringToChange As String) As String
strStringToChange = replace(strStringToChange,"ó","o")
strStringToChange = replace(strStringToChange,"í","i")
'Add as many as you like
'Then delete all remaing
Dim x As Integer
For x = 1 To Asc("A")
strStringToChange = Replace(strStringToChange, Chr(x), "")
Next x
For x = Asc("z") To 255
strStringToChange = Replace(strStringToChange, Chr(x), "")
Next x
FixString = strStringToChange
End Function
'-------------EndCode2
Plug that in and then try
? FixString ("Róis1ín")
in the debug window