
21.04.2014, 20:29
|
Прохожий
|
|
Регистрация: 21.04.2014
Сообщения: 2
Версия Delphi: Delphi 7
Репутация: 10
|
|
Цитата:
Сообщение от NumLock
добавить в список uses модуль, где объявлена глобальная переменная.
|
Меняя ComboBox и нажимаю кнопку в форму всегда 0 передает, может не так назначаю mat ?
форма 1
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mat:Integer;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
mat:=ComboBox1.ItemIndex;
Form2.Visible:=True;
end;
end.
форма 2
Код:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
if mat=1 then
Edit1.Text:='первая';
if mat=2 then
Edit1.Text:='вторая';
if mat=0 then
Edit1.Text:='ноль';
end;
end.
|