有几个函数定义在本程序的其它unit上了,我可不可以直接调用,我怎么调用才不会出错?
解决方案 »
- DBGrideh某一列如何显示成checkbox
- 我做好的ACTIVEFORM控件为啥在客户端没有自动更新下载新的版本
- DLL中如何共享BDE数据库连接呀!
- 请问:如何把一个文本文件中的内容全部读入一个strfile 变量中?
- 史上最强!超级矢量图形开发控件!Delphi开发示例!
- UDP通信问题
- 一个关于空记录的的问题!
- 通过DLL创建的线程与主程序创建的线程在CPU时间上的占用是否相同?可调吗?
- TechnoFantasy(www.applevb.com) windoze(瞌睡窗) 能否交个朋友 qq:41233280
- 请问可以用Delphi开发一个控件然后拿给VB用吗?
- 关于菜单融合的问题!
- 关于组件介绍的书有么,在哪下载呀
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;implementationuses Unit2; //这里引用 Unit2{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
form2.asdf; //这里调用 Unit2的函数
end;end.
==================================================================
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure asdf; //在这里声明
end;var
Form2: TForm2;implementation{$R *.dfm}procedure TForm2.asdf; //实现部分
begin
showMessage('http://www.goomoo.net');
end;end.
然后调用就可以了
for example;
uses unitname
procedure TfrmBillManage.ToolButton3Click(Sender: TObject);
begin
unitname.FunctionNameOrProcedureName;
end;
然后调用就可以了
for example;
uses unitname
procedure TfrmBillManage.ToolButton3Click(Sender: TObject);
begin
unitname.FunctionNameOrProcedureName;
end;
然后调用就可以了
for example;
uses unitname
procedure TfrmBillManage.ToolButton3Click(Sender: TObject);
begin
unitname.FunctionNameOrProcedureName;
end;
function goalnumber(var s:String):String;
var
i,lengthofnumber:integer; goalstr:string;
begin
lengthofnumber:=length(s);
if lengthofnumber mod 2=0 then
begin
i:=1;
goalstr:='';
while i<lengthofnumber do
begin
goalstr:=goalstr+s[i+1];
goalstr:=goalstr+s[i];
i:=i+2;
end;
end
else
begin
i:=1;
goalstr:='';
while i<lengthofnumber-1 do
begin
goalstr:=goalstr+s[i+1];
goalstr:=goalstr+s[i];
i:=i+2;
end;
goalstr:=goalstr+'F';
goalstr:=goalstr+s[i];
end; Result:=goalstr;
end ;
如上所示,我的函数是这样定义的:
function goalnumber(var s:String):String;
而不是function TForm2.goalnumber(var s:String):String;所以我用users unit2声明后仍然出错不能调用。