unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    ListBox1: TListBox;
    ListBox2: TListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Button1: TButton;
    procedure ListBox1KeyPress(Sender: TObject; var Key: Char);
    procedure ListBox2KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm3.ListBox1KeyPress(Sender: TObject; var Key: Char);
begin
    if (key=#13)and (Form3.ListBox1.Items.Strings[Form3.ListBox1.ItemIndex]<>'')
   then begin
      num1:=Form3.Listbox1.ItemIndex;
      Form3.ListBox1.Enabled:=false;
      Form3.ListBox2.Enabled:=true;
      Form3.ActiveControl:=ListBox2;
   end;
end;

procedure TForm3.ListBox2KeyPress(Sender: TObject; var Key: Char);
begin
     If key=#13 then begin
        case Form3.ListBox2.ItemIndex of
           0: num2:=0;
           1: num2:=1;
           2: num2:=2;
           3: num2:=3;
        end;
        if num1=num2 then begin
           Form3.Label4.Caption:='Верно';
           countr:=countr+1;
           Form3.ListBox2.Enabled:=false;
           Form3.ListBox1.Enabled:=true;
           Form3.ActiveControl:=ListBox1;
           Form3.ListBox1.Items.Delete(num1);
           Form3.ListBox2.Items.Delete(num2);
            if countr=3 then showmessage('Тест окончен');
        end
        else begin
           Form3.Label4.Caption:='Ошибка';
         end;
        end;
     end;

end.
