| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 749 人关注过本帖
标题:写成函数,就找不到控件了
只看楼主 加入收藏
angel725
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-11-5
结帖率:0
收藏
 问题点数:0 回复次数:3 
写成函数,就找不到控件了

unit GG;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, ExtCtrls, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Timer1: TTimer;
IdHTTP1: TIdHTTP;
procedure Timer1Timer(Sender: TObject);

private
{ Private declarations }

public
{ Public declarations }
end;

var
Form1: TForm1;

implementation


{$R *.dfm}
function zhonghang():string;
begin

with TStringList.Create do try
Text := IdHTTP1.Get('http://www.xxx.com');
if Count > 2 then
begin
edit1.Text:= Copy(Strings[Count - 2], 0, 8);
edit2.Text:= Copy(Strings[Count - 2], 0, 8);
end;
finally
Free;
end;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
zhonghang();
end;

end.
错误:
[Error] GGold.pas(47): Undeclared identifier: 'IdHTTP1'
[Error] GGold.pas(50): Undeclared identifier: 'edit1'
[Error] GGold.pas(51): Undeclared identifier: 'edit2'


这段不对了??
找不到控件,
函数放错位置了?

搜索更多相关主题的帖子: 函数 控件 declarations TEdit uses 
2006-11-05 01:13
泡泡2代
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-11-5
收藏
得分:0 

写成过程吧
函数里面不能这样些
如果要这样些,就要把IDHTTP1,EDIT1,EDIT2都作为参数输入

2006-11-05 02:58
xu2000
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:51
帖 子:3890
专家分:56
注 册:2006-4-8
收藏
得分:0 
Text := IdHTTP1.Get('http://www.xxx.com');
text是哪的属性>

我会拿出我全部的钱财,以保你衣食无忧。我会献出我所有的智慧,以助你一帆风顺。我会想到所有的笑语,以令你展眉开颜。我会挤出最长的时间,以使你终生幸福。        [本人原创的结婚宣言]
2006-11-05 11:47
散人
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-11-12
收藏
得分:0 
function zhonghang():string;
都没返回值,当然用过程了
edit1.Text:= Copy(Strings[Count - 2], 0, 8);
edit2.Text:= Copy(Strings[Count - 2], 0, 8);
这里组件不可以写入函数或过程
2006-11-12 21:43
快速回复:写成函数,就找不到控件了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014592 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved