?
Solved

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

Posted on 2007-10-10
5
Medium Priority
?
2,843 Views
Last Modified: 2009-07-27
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.
0
Comment
Question by:ding-dong
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 20047502
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
 
LVL 6

Accepted Solution

by:
bokist earned 260 total points
ID: 20047582
Try onKeyPress event,  something like this

  if  Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|']  then Key := #0;
0
 
LVL 19

Assisted Solution

by:MerijnB
MerijnB earned 240 total points
ID: 20047587
that would be

  if  (Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|'])  then Key := #0;
0
 

Author Comment

by:ding-dong
ID: 20047589
Either would be acceptable, would be better not allowing them to be entered in the first place.
0
 

Author Comment

by:ding-dong
ID: 20047627
Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question