Показать сообщение отдельно
  #4  
Старый 21.01.2009, 17:43
Аватар для Vayrus
Vayrus Vayrus вне форума
Исполняемый Ретровирус
 
Регистрация: 09.08.2008
Адрес: Umbrella Corporation
Сообщения: 743
Репутация: 1293
По умолчанию

Код:
function UpCase(ch: char): char;

begin

if (ch in ['a'..'z', 'а'..'я'])

   then result := chr(ord(ch) - 32)

   else result := ch;

end;

 

function LoCase(ch: char): char;

begin

if (ch in ['A'..'Z', 'А'..'Я'])

   then result := chr(ord(ch) + 32)

   else result := ch;

end;

 

function UpperCase(s: string): string;

var

i: integer;

begin

result := s;

for i := 1 to length(result) do

   if (result[i] in ['a'..'z', 'а'..'я'])

     then result[i] := chr(ord(result[i]) - 32);

end;

 

function LowerCase(s: string): string;

var

i: integer;

begin

result := s;

for i := 1 to length(result) do

   if (result[i] in ['A'..'Z', 'А'..'Я'])

     then result[i] := chr(ord(result[i]) + 32);

end;

 

procedure TForm1.Button1Click(Sender: TObject);

const

s = 'zZцЦ.';

var

i: integer;

begin

Form1.Caption := 'DownCase: ';

for i := 1 to Length(s) do

   Form1.Caption := Form1.Caption + LoCase(s[i]);

Form1.Caption := Form1.Caption + ' UpCase: ';

for i := 1 to Length(s) do

   Form1.Caption := Form1.Caption + UpCase(s[i]);

Form1.Caption := Form1.Caption + ' UpperCase: ' +

   UpperCase(s);

Form1.Caption := Form1.Caption + ' LowerCase: ' +

   LowerCase(s);

end;

Взято из Delphi Russian Knowledge Base
Ответить с цитированием