在implementation语句的上面,一般会有这样的几个句子
var
  Form1: TForm1;implementation
我习惯在这里定义全局变量,
比如
var
  Form1: TForm1;
  searched:Boolean;implementation
不知道对了没?

解决方案 »

  1.   

    在implementation上面定义
    var 
    searched:boolean;
      

  2.   

    你只要在public下定义变量就可以了!
    public
    searched:boolean;
      

  3.   

    procedure tform.filelistboxclick(sender:tobject);
    begin
      if searched then
      begin
        searched:=false;
        listbox1.item.clear;
        label5.caption:=''
      end;
    请问书中说searched是全局变量,用于表明LISTBOX1当前显示内容是查找的结果还是从FILELISTBOX1中选定文件,什么意思,是不是SEARCHED要定义为全局变量,如何定义呢。
    //定义全局变量上面已经说了,但是至于你所写的意思,我觉得你在其他的过程
    //中肯定要对searched赋值。
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Db, DBTables, Grids, DBGrids, FileCtrl;type
      TForm1 = class(TForm)
        FileListBox1: TFileListBox;
        procedure FileListBox1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      searched:Boolean;   ///////////////////在这里implementation{$R *.DFM}procedure TForm1.FileListBox1Click(Sender: TObject);
    begin
      if searched then
      begin
        searched:=false;
        listbox1.item.clear;
        label5.caption:=''
      end;
    end;end.
      

  5.   

    一般我们在public里面定义全局变量,如上面的所说,我们在var……implementation之间定义也可以作为全局变量!
      

  6.   

    Delphi Pascal有两种全局变量:
    1。全局变量:如果用户在单元的Interface部分声明的一个变量,她的作用域将扩展到任何声明使用它的单元中。
    2。隐含全局变量:如果用户在单元implementation部分里生命一个变量,她的作用域是这个单元。版权归属Marco Cantu--The end;
      

  7.   

    Interface部分又包含有Private和Public两部分,这两部分定义的东东也不一样啊,怎么不一样?大家都知道。