Код формы:
-------------------------------
object Form1: TForm1
Left = 566
Top = 225
Width = 616
Height = 79
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 0
Top = 0
Width = 601
Height = 21
MaxLength = 20
TabOrder = 0
OnKeyUp = Edit1KeyUp //Это важно:)
end
object Edit2: TEdit
Left = 0
Top = 24
Width = 553
Height = 21
Color = clMenu
ReadOnly = True
TabOrder = 1
end
object Edit3: TEdit
Left = 560
Top = 24
Width = 41
Height = 21
AutoSize = False
Color = clMenuBar
ReadOnly = True
TabOrder = 2
end
end
===============
Код самой программы... Так сказать
-------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Edit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s : string;
b, k: byte;
begin
k := 0;
s := Edit1.Text;
while (pos('max', s) > 0) do
begin
b := pos('max', s);
delete(s, b, 3);
insert('min', s, b);
inc(k);
end;
while (pos('макс', s) > 0) do
begin
b := pos('макс', s);
delete(s, b, 4);
insert('мин', s, b);
inc(k);
end;
Edit3.Text := IntToStr(k);
Edit2.Text := s;
end;
end.