下面错误显示ListBox1Add是个未定义的标示符,显然你点打错位置了,应该在add前面。

解决方案 »

  1.   

    太粗心了吧,这么低级的错误也犯,应该是ListBox1.Add
      

  2.   

    你窗口中有ListBox1这个控件吗?没有就拖一个上去
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        Button2: TButton;
        Memo1: TMemo;
        OpenDialog1: TOpenDialog;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function searchfile(path:string):TStringList;
    var SearchRec:TSearchRec;
        found:integer;
        list:TStringList;
    begin
      list:=TStringList.Create;
      found:=FindFirst(path+'\*.*',faAnyFile,SearchRec);
      while  found=0 do
      begin
        if (SearchRec.Name<>'.')  and (SearchRec.Name<>'..') and (SearchRec.Attr<>faDirectory)
          then List.Add(SearchRec.Name);
        found:=FindNext(SearchRec);
      end;
      FindClose(SearchRec);
      searchfile:=list;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Memo1.Lines:=searchfile(Edit1.Text);
    end;end.上述代码,已经修改,并执行通过。目录录入Edit1.Text中。搜索的文件,存入Memo1。
      

  4.   

    少加了一个点,还有uses没有引用
      

  5.   

    真的非常谢谢  lyhoo163  
      

  6.   

    那如果  Memo1控件中输出出来的是同名文件 (同名文件样本:wenjian.rtf     wenjian.txt) 无所谓什么类型  那该改些什么