运行总是提示如下信息
[Error] Unit1.pas(25): Unsatisfied forward or external declaration: 'TForm1.ProfitCount'
代码如下:请帮忙改改!
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label3: TLabel;
    Edit3: TEdit;
  private
    { Private declarations }
  public
    { Public declarations }
    function ProfitCount(x,Y:Integer;Z:real):Real;
  end;var
  Form1: TForm1;implementation{$R *.dfm}
 function ProfitCount(x,Y:Integer;Z:real):Real;
   begin
     result:=(x/z)-y;
   end;end.

解决方案 »

  1.   

    TForm1.ProfitCount------------------------------------------------------------------------------
    金盆洗澡    重出江湖     打劫.抢分   掀起一场腥风血雨   戒烟攒钱 只为换新车
      

  2.   

    implementation{$R *.dfm}
     function ProfitCount(x,Y:Integer;Z:real):Real;
       begin
         result:=(x/z)-y;
       end;
    这里应该是:
    implementation{$R *.dfm}
     function Tform1.ProfitCount(x,Y:Integer;Z:real):Real;
       begin
         result:=(x/z)-y;
       end;
      

  3.   

    你没有把函数加到tform1里怎么用啊
      

  4.   

    不用加
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function ProfitCount(x,Y:Integer;Z:real):Real;
       begin
         result:=(x/z)-y;
       end;
       procedure TForm1.Button1Click(Sender: TObject);
    begin
        showmessage(vartostr(profitcount(6,3,1)));
    end;end.
      

  5.   

    两种解决方法:
    一是把public里面的声明去掉
    二是带着声明,在下面的函数部分加form1.,如一楼所说
      

  6.   

    楼主难道是手工写的代码……在类里声明完了后直接ctr+alt+shift+C 就成了阿
      

  7.   

    -_-!!!!!!又错了是ctr+shift+C
      

  8.   

    要么就写类的成员函数,要么就不写,
    1:type
      TForm1 = class(TForm)       
      private
        { Private declarations }
      public
        { Public declarations }
        function ProfitCount(x,Y:Integer;Z:real):Real;//如果这样声明
      end;
    function Tform1.ProfitCount(x,Y:Integer;Z:real):Real;//则必须这样定义
       begin
         result:=(x/z)-y;
       end;
    2:implementation{$R *.dfm}
    function ProfitCount(x,Y:Integer;Z:real):Real;//如果是这样,则用的时侯直接调用就可。
    begin
    do something;
    end;