procedure TForm1.Button3Click(Sender: TObject);  //57
begin
 if ColorDialog1.Execute then
        memo1.Font.Color:=ColorDialog1.Color;end;[Error] Unit1.pas(57): Statement expected but 'PROCEDURE' found什么意思呀,不懂呀,一共用了4个dialog,save,open,font和color,每个BUTTON都出类似的问题!

解决方案 »

  1.   

    我想是其他的内容导致DELPHI认为57行出现问题。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        ColorDialog1: TColorDialog;
        Button1: TButton;
        Memo1: TMemo;
        Button2: TButton;
        Button3: TButton;
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button3Click(Sender: TObject);
    begin
     if ColorDialog1.Execute then
            memo1.Font.Color:=ColorDialog1.Color;
    end;end.上面的是测试内容,并没有出现你所说的错误。你给出的只是一个片断,把整个单元放出来,问题出在其他地方。
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        OpenDialog1: TOpenDialog;
        SaveDialog1: TSaveDialog;
        FontDialog1: TFontDialog;
        ColorDialog1: TColorDialog;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        procedure Button5Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);  private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button5Click(Sender: TObject);
    begin
    close;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    try
    if OpenDialog1.Execute then
      begin
        memo1.Lines.Clear ;
        memo1.Lines.LoadFromFile(OpenDialog1.FileName );
      end;
    except On E:EreadError do
      showmessage('此文件打开失败!');  
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
     if ColorDialog1.Execute then
            memo1.Font.Color:=ColorDialog1.Color;end;procedure TForm1.Button4Click(Sender: TObject);
    begin
    try
      if SaveDialog1.Execute then
        memo1.Lines.SaveToFile(SaveDialog1.FileName);
        except ON E:EreadError do
         showmessage('此文件打开失败!');
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    if FontDialog1.Execute then
          memo1.Font:=FontDialog1.Font;
    end;end.
    这是全部内容了!!
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    try
    if OpenDialog1.Execute then
      begin
        memo1.Lines.Clear ;
        memo1.Lines.LoadFromFile(OpenDialog1.FileName );
      end;
    except On E:EreadError do
      showmessage('此文件打开失败!'); 
    end;//注意哦! 
    end;
      

  4.   

    Button1的异常块最后少了个end:
    try
      ....
    finally
      ....
    end;
      

  5.   

    另外,需要提醒楼主一点,这里完全可以这样写:
    try
      if OpenDialog1.Execute then
      begin
        Memo1.Lines.Clear ;
        Memo1.Lines.LoadFromFile(OpenDialog1.FileName );
      end;
    except 
      On EreadError.Create('此文件打开失败!'); 
    end;