?
Solved

how to use alphabetical EditMask?

Posted on 2003-02-26
7
Medium Priority
?
200 Views
Last Modified: 2010-04-04
i want to only allow users to input characters of the alphabet in a TEdit

from the help file, it says

"The L character requires an alphabetic character only in this position"

so i put 'LLLLL' for the EditMask
but now the edit only allows the character L...
is there something missing?

i don't quite understand the usage of '!' and '\'.
am i supposed to put one of those infront of each 'L' ?

there's no example for alphabetical EditMasks in Help.

thanks in advance.


ViV
0
Comment
Question by:sohmuijai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 34

Expert Comment

by:Slick812
ID: 8031224
hello sohmuijai, you might put this code in your edit's OnKeyPress Event

procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
if Ord(Key) = 8 then Exit;
if (Ord(Key) < Ord('a')) or (Ord(Key) > Ord('z')) then
if (Ord(Key) < Ord('A')) or (Ord(Key) > Ord('Z')) then
Key := #0;
end;
0
 
LVL 34

Expert Comment

by:Slick812
ID: 8031225
that's for a Regular TEdit, , , NOT a MaskEdit
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8031380
procedure TForm1.MaskEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Ord(Key) = 8 then Exit else
  if Key in ['A'..'Z', 'a'..'z'] then Key := #0;
end;

That's rather more clear, isn't it? ;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sohmuijai
ID: 8031385
hmm..
but i would like to use the EditMask property...

maybe i should also tell u that i need the input as
'num num P E/U/C num num num num num num'
eg. '03PE123456'

right now, i put EditMask as '00PL000000'
i can correctly check input until '03P'
but the 4th character is only accepting 'L'..
which i do not want...


ViV
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 8031388
it should be:

procedure TForm1.MaskEdit1KeyPress(Sender: TObject; var Key: Char);
begin
 if Ord(Key) = 8 then Exit else
 if not (Key in ['A'..'Z', 'a'..'z']) then Key := #0;
end;

sorry =)
0
 
LVL 17

Accepted Solution

by:
geobul earned 60 total points
ID: 8031481
Hi,

Your mask works well on my computer. Try that mask in a form without any additional code. Create a new project, add one TMaskEdit and set its EditMask property to '00PL000000'. Run the project and test the mask.

I suppose that there is code written by you which interferes with the mask.

Regards, Geo
0
 

Author Comment

by:sohmuijai
ID: 8031514
hmm... does it have to be a TMaskEdit?

i'm using a derived TEdit called TZEdit by some other person that also has the EditMask property...
maybe the derivation wasn't very good.....

thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 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