在implementation下使用uses unitname 进行声明 然后调用就可以了 for example; uses unitname procedure TfrmBillManage.ToolButton3Click(Sender: TObject); begin unitname.FunctionNameOrProcedureName; end;
在implementation下使用uses unitname 进行声明 然后调用就可以了 for example; uses unitname procedure TfrmBillManage.ToolButton3Click(Sender: TObject); begin unitname.FunctionNameOrProcedureName; end;
在implementation下使用uses unitname 进行声明 然后调用就可以了 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声明后仍然出错不能调用。
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声明后仍然出错不能调用。