关于如何判断edit的内容 是否为大写字母,并且报错!(100分)

  • 主题发起人 jarod9999
  • 开始时间
J

jarod9999

Unregistered / Unconfirmed
GUEST, unregistred user!
看过有过类似的帖子
但是用里面的方法 却没有用
请问能不能给个详细的
谢拉
 
type
CharSets=('A'.'B'..'Z');
var
s:string;
i:integer;
begin
s:=trim(edit2.text);
for i:=0 to high(s)-1do
if not (s in charset) then
raise exception.create('Error!');
end;

hehe....不知道行不行。。。
 
showMessage(intToStr(ord('A')));
根据ASC值来判断就OK了
 
procedure checkupper(str:string);
var i:integer;
begin
for i:=0 to length(str)-1do
if (str>='A') and (str<='Z') then
raise Exception.Create('第'+inttostr(i+1)+'个字母是大写!');
end;
 
在OnKeyPress里面的Key就是Char类型。
if pos(Key,'ABCDEFG......XYZ')=0 then

ShowMessage('请使用大写字母.');
 
if pos(Key,'ABCDEFGHIJKLMNOPQRSTXYZ')=0 then

begin
ShowMessage('请使用大写字母.');
key:=#0;
end;
 
还是没用,不知道那里出问题了
 
为什么不用maskedit?
 
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['A'..'Z']) then
key:=#0;
end;
 
对不起,没看清题:
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['A'..'Z']) then
begin
showmessage('输入错误,请收入大写字母。');
key:=#0;
end;
end;
 
if UpperCase(Edit1.Text) <> Edit1.Text then
raise exception.create('Error!');
 
楼上的最简单了!!!!!!!!!!!!!!!!!!!!!!!!!11
 
for i:=1 to length(edit1.text)do
if UpperCase(Edit1.Text) <> Edit1.Text then
showmessage('Error!');
 

Similar threads

S
回复
0
查看
950
SUNSTONE的Delphi笔记
S
S
回复
0
查看
772
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部