Скачиваний:
56
Добавлен:
11.02.2014
Размер:
11.28 Кб
Скачать

unit Unit1;

{$mode objfpc}{$H+}

interface

uses

Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,

Buttons;

type

{ TForm1 }

TForm1 = class(TForm)

BitBtn1: TBitBtn;

ComboBox1: TComboBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure ComboBox1Click(Sender: TObject);

procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure FormActivate(Sender: TObject);

private

{ private declarations }

public

{ public declarations }

end;

var

Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormActivate(Sender: TObject);

begin

ComboBox1.SetFocus;

end;

procedure TForm1.ComboBox1Click(Sender: TObject);

var

st : string;

n,i,nst,ind: integer;

begin

n:=0;

ind:=0;

nst:=ComboBox1.ItemIndex;

st:=Combobox1.Items[nst];

for i:=1 to Length(st) do

case ind of

0 : if st[i]<>' ' then

begin

ind:=1;

n:=n+1;

end;

1 : if st[i]=' ' then

ind:=0;

end;

Label3.Caption:=IntToStr(n);

end;

procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if key=13 then

begin

ComboBox1.Items.Add(ComboBox1.Text);

ComboBox1.Text:='';

end;

end;

initialization

{$I unit1.lrs}

end.