unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public { Public declarations } end;var
Form1: TForm1;implementation{$R *.dfm}
function readFromFile:string;
var s,s2:string; F:TextFile;
begin
OpenDialog1.FileName:='';
OpenDialog1.Filter:='*.XML|*.xml';
s:=''; result:='';
if not OpenDialog1.Execute then exit; assignfile(F,OpenDialog1.FileName);
try
Reset(F);
while not Eof(F) do
begin
Readln(F, s2);
s:=s+s2;
end;
result:=s;
finally
closefile(f);
end;
end;运行就提示: Undeclared identifier: 'OpenDialog1',帮我看看,哪儿问题
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public { Public declarations } end;var
Form1: TForm1;implementation{$R *.dfm}
function readFromFile:string;
var s,s2:string; F:TextFile;
begin
OpenDialog1.FileName:='';
OpenDialog1.Filter:='*.XML|*.xml';
s:=''; result:='';
if not OpenDialog1.Execute then exit; assignfile(F,OpenDialog1.FileName);
try
Reset(F);
while not Eof(F) do
begin
Readln(F, s2);
s:=s+s2;
end;
result:=s;
finally
closefile(f);
end;
end;运行就提示: Undeclared identifier: 'OpenDialog1',帮我看看,哪儿问题
解决方案 »
- Form在Create的时候,为什么触发了好多组件的editValueChanged事件呢?
- 对表写循环
- 无法理解的问题!贴出我的代码!~!~,最常用的,最简单的功能,尽然有错?
- 在线急等 大家帮帮忙~~谢谢
- 常用的Delphi第三方控件主要有哪些,如何安装?
- 高分求教:如何在网络打印机打印纸时右下角打印工作站名称和统计各工作站打的纸数
- 【求助】TSQLQuery(dbexpress)如何调用oracle中的存储过程 ,知道调用sqlserver的也帮我讲讲
- 如何强制杀死用友华表控件
- WaitForSingleObject用法(原来的错了,不知跑那了)。
- 想不通!!!!!!!
- 求打印dbgrid数据的程序代码
- 内存映射的概念问题
begin......end;
function TForm1.readFromFile:string;
如:form1.OpenDialog1
{ Private declarations }
//这加上
function readFromFile:string;//这改为
$R *.dfm}
function TFrom1.readFromFile:string;
var s,s2:string; F:TextFile;
begin...
var
s,s2:string;
F:TextFile;
OpenDialog1: TOpenDialog;
begin
OpenDialog1 := TOpenDialog.Create(nil);
try
OpenDialog1.FileName:='';
OpenDialog1.Filter:='*.XML|*.xml';
s:=''; result:='';
if not OpenDialog1.Execute then exit;
assignfile(F,OpenDialog1.FileName);
try
Reset(F);
while not Eof(F) do
begin
Readln(F, s2);
s:=s+s2;
end;
result:=s;
finally
closefile(f);
end;
finally
OpenDialog1.free;
end;
end;