注册 登录
编程论坛 Delphi论坛

问个问题为什么我在delphi7.0中编译错误

kkllchun 发布于 2010-11-28 00:24, 784 次点击
unit csmain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,csst;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
   begin
   csstart;
   end;
end.


//下面是一个单元
unit csst;
interface
uses
 Dialogs;

implementation
procedure csstart;
begin
showmessage('测试成功');
end;
end.


//编译不通过奇怪了! 我是测试把其中的一块拿出来写个单元,这样更清晰些,但是测试的时候不通过啊.
  我觉得我的代码没有问题,因该是编译器的问题
  哪位大哥能指点下这个问题,这样我就少走好多弯路了.
2 回复
#2
yeye552010-11-28 14:36
电脑就是女朋友,她绝对没有错,有错只能是你错。编译器也是一样。

//下面是一个单元
unit csst;
interface
uses
Dialogs;

procedure csstart;

implementation
procedure csstart;
begin
showmessage('测试成功');
end;
end.

一个单元中的函数如果要在其它单元中调用,这个函数必需在implementation之前进行声明。这样其它单元才可以“看见”这个函数。如果不声明,表示这个函数是本单元私有的。

这个问题属于基本语法结构,建议找本书系统学习。
#3
kkllchun2010-11-28 17:09
虽然已经自己解决了,但还是谢谢!谢谢这位大哥的帮助!
1