回 帖 发 新 帖 刷新版面

主题:请问DELPHI如果引用其它表变量

    我的FROM1为登陆表单。我的FROM需要引用FROM1的登陆ID。我想在FROM1里设一变量储存登陆ID。然后FROM2再引用这个变量。
    看书上说在INTERFACE里定义变量就可以让其他FROM引用。但我还是引用不了。
(FROM1)
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons,DateModule,BookLend;
Var
  LoginID:string;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    UName: TEdit;
    Upwd: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
var
  count:integer;

{$R *.dfm}

(FROM2)
unit BookLend;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DateModule,Grids, DBGrids, StdCtrls, ExtCtrls, DBCtrls, Mask,
  ComCtrls, DB,ADODB;

type
  TBook_lend = class(TForm)
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    BookLendQuery: TADOQuery;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Book_lend: TBook_lend;

implementation

uses
  login;

{$R *.dfm}

请问应该怎样修改?

回复列表 (共1个回复)

沙发

unit Login;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    UName: TEdit;
    Upwd: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
                        
                            LoginID:string;
  end;

var
  Form1: TForm1;

implementation
var
  count:integer;

{$R *.dfm}

(FROM2)
unit BookLend;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DateModule,Grids, DBGrids, StdCtrls, ExtCtrls, DBCtrls, Mask,
  ComCtrls, DB,ADODB;

type
  TBook_lend = class(TForm)
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    BookLendQuery: TADOQuery;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Book_lend: TBook_lend;
  Loginid:string;

implementation

uses
  login;

{$R *.dfm}

请问应该怎样修改?
然后拿Book_lend的loginid:=frm_login.loginid

我来回复

您尚未登录,请登录后再回复。点此登录或注册