注册 登录
编程论坛 Delphi论坛

写成函数,就找不到控件了

angel725 发布于 2006-11-05 01:13, 765 次点击

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'


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

3 回复
#2
泡泡2代2006-11-05 02:58

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

#3
xu20002006-11-05 11:47
Text := IdHTTP1.Get('http://www.xxx.com');
text是哪的属性>
#4
散人2006-11-12 21:43
function zhonghang():string;
都没返回值,当然用过程了
edit1.Text:= Copy(Strings[Count - 2], 0, 8);
edit2.Text:= Copy(Strings[Count - 2], 0, 8);
这里组件不可以写入函数或过程
1