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;
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;
对不起,没看清题:
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['A'..'Z']) then
begin
showmessage('输入错误,请收入大写字母。');
key:=#0;
end;
end;