社区
语言基础/算法/系统设计
帖子详情
请教高手:unit2 如何调用 unit1中的函数呀?
yan32711
2009-07-26 08:50:52
如题:
...全文
269
25
打赏
收藏
请教高手:unit2 如何调用 unit1中的函数呀?
如题:
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
25 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ok1411
2009-07-30
打赏
举报
回复
孺子可教也
慢慢来- -
zshsuming
2009-07-29
打赏
举报
回复
楼主,你这样学习态度可不行啊,uint1和uint2只不过是个名称,你应该在大学给你讲解和指导的同时,进行思考,不明白的地方先去找书去看看,然后再来问。
hujun_zero
2009-07-28
打赏
举报
回复
这个帖子也顶得忒高了
hljiayou
2009-07-28
打赏
举报
回复
[Quote=引用 21 楼 yan32711 的回复:]
这么看来,是不需要在public中声明函数了,只要在需要调用的unit中写上used+调用的unit即可?
[/Quote]
差不多,在要调用的unit中的implementation下写uses + 调用的unit名字,就可以调用其中的属性、方法
yan32711
2009-07-28
打赏
举报
回复
这么看来,是不需要在public中声明函数了,只要在需要调用的unit中写上used+调用的unit即可?
yan32711
2009-07-28
打赏
举报
回复
8楼写的似乎是uint1调用uint2,而非uint2调用uint1?是这样吧?
macchen1224
2009-07-28
打赏
举报
回复
你好,請先use unit2,然後使用請用form2.,即可參考到你要的form2內的東西了。
hljiayou
2009-07-28
打赏
举报
回复
[Quote=引用 17 楼 yan32711 的回复:]
8楼写的似乎是uint1调用uint2,而非uint2调用uint1?是这样吧?
[/Quote]
反过来用就可以了。
hljiayou
2009-07-28
打赏
举报
回复
[Quote=引用 14 楼 yan32711 的回复:]
请教:我在unit1的public中声明unit2中要调用的函数TexToBuf后,编译有eror:unsatisfied forword or extrnal declaration:'TFORM1.TexToBuf'.可是我并没有找到其他地方的声明。这是怎么回事呀?
[/Quote]
在你的函数前面加上TForm1.
火龙岛主
2009-07-27
打赏
举报
回复
unit2.function1(10)
yan32711
2009-07-27
打赏
举报
回复
谢谢大家哈,我试试。
zz1001
2009-07-27
打赏
举报
回复
[Quote=引用 8 楼 zshsuming 的回复:]
unit Unit2;
interface
uses dialogs;
procedure hello;
implementation
procedure hello;
begin
ShowMessage('hello world');
end;
end.
unit Unit1;
interface
uses
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
uses unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
hello;
end;
end.
[/Quote]
支持,写得经典
贝隆
2009-07-27
打赏
举报
回复
文件-》Use Unit
yan32711
2009-07-27
打赏
举报
回复
请教:我在unit1的public中声明unit2中要调用的函数TexToBuf后,编译有eror:unsatisfied forword or extrnal declaration:'TFORM1.TexToBuf'.可是我并没有找到其他地方的声明。这是怎么回事呀?
msky850917
2009-07-27
打赏
举报
回复
unit1里把函数定义为public类型的
unit2里 use unit1
然后form2.函数 的形式调用unit1里面的函数
yan32711
2009-07-27
打赏
举报
回复
我在unit1的public中声明unit2中要调用的函数TexToBuf后,编译有eror:unsatisfied forword or extrnal declaration:'TFORM1.TexToBuf'.可是我并没有找到其他地方的声明。这是怎么回事呀?
hljiayou
2009-07-27
打赏
举报
回复
如果是系统的单元文件,直接在uses后面添加
如果是自定义的单元文件,需要互相使用的话,就在implementation之后uses添加一下要使用的单元文件名
米的向日葵
2009-07-27
打赏
举报
回复
楼上的楼上真详细
bewild
2009-07-27
打赏
举报
回复
楼上真详细
zshsuming
2009-07-27
打赏
举报
回复
unit Unit2;
interface
uses dialogs;
procedure hello;
implementation
procedure hello;
begin
ShowMessage('hello world');
end;
end.
unit Unit1;
interface
uses
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
uses unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
hello;
end;
end.
加载更多回复(5)
黑马程序员-美多商城完整项目代码.zip
黑马程序员 大事件Springboot3+vue3项目
M800VM80V系列 编程说明书(L系) ib1501636-1501637chng.pdf
M800VM80V系列 编程说明书(L系) ib1501636-1501637chng
新年烟花代码HTML5-下载即用.zip
源码下载地址: https://pan.quark.cn/s/a9b188c0f76b FireWorks 基于Html+Canvas写的一个2023年3D跨年烟花代码、可以自己修改字以及音乐 image image image
基于 Streamlit + LangChain + DeepSeek 构建的智能知识库问答应用,支持文档上传、向量库构建和智能问答
网上关于LLM大模型构建知识库的理论知识挺多的,但能跑通的代码比较少。此资源对LLM大模型的学习有很大的帮忙。
黑马程序员的Linux网络编程学习记录.zip
黑马程序员 大事件Springboot3+vue3项目
语言基础/算法/系统设计
16,742
社区成员
33,234
社区内容
发帖
与我相关
我的任务
语言基础/算法/系统设计
Delphi 语言基础/算法/系统设计
复制链接
扫一扫
分享
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章