Testing for special characters \ / : * ? " < > |

In delphi, I have an edit box and I need to test each character to make sure its not one of the following: \ / : * ? " < > | and if it is, it needs to be removed. How can I find out if one of the symobls are entered. I know I can test them on key presses but I dont know what to compare them to.
ding-dongAsked:
Who is Participating?
 
bokistConnect With a Mentor Commented:
Try onKeyPress event,  something like this

  if  Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|']  then Key := #0;
0
 
MerijnBSr. Software EngineerCommented:
do you want to filter then, so the user can't insert them in the first place, or do you want to remove them afterwards?
0
 
MerijnBConnect With a Mentor Sr. Software EngineerCommented:
that would be

  if  (Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|'])  then Key := #0;
0
 
ding-dongAuthor Commented:
Either would be acceptable, would be better not allowing them to be entered in the first place.
0
 
ding-dongAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.