请大家帮忙看看问题出在哪
以下是我在在网上找到的程序,我添加了控件ListBox1后但程序报错
“[Error] Unit1.pas(50): Undeclared identifier: 'ListBox1'
[Error] Unit1.pas(50): Missing operator or semicolon”
请帮我看看如何修改,谢谢!
procedure GetXMLFile(pathname: string);
var
FindData: TWin32FindData;
hf:THandle;
b:boolean;
tmpstr:string;
tempFolder:string;
str:string;
begin
hf := Windows.FindFirstFile(PChar(pathname + '\*.*'), FindData);
if hf = INVALID_HANDLE_VALUE then exit;
b := true;
while b do
begin
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
str:=string(FindData.cFileName);
if (length(str)>5) and (copy(str,length(str)-3,4)='.xml') then
begin
ListBox1.Items.Add(PathName+'\'+string(FindData.cFileName)); //这行报错
end;
end
else
begin
tmpstr := FindData.cFileName + '';
if (tmpstr <> '.') and (tmpstr <> '..') then
begin
tempFolder:=tempFolder+string(FindData.cFileName)+'\';
GetXMLFile(pathname + '\' + FindData.cFileName);
end;
end;
b := windows.FindNextFile(hf,FindData);
end;
end;
[解决办法]
Delphi丢失了ListBox1的定义部份代码
在界面上把ListBox1删了,再重新拖一个ListBox上去.
[解决办法]
(length(str) >5) and (copy(str,length(str)-3,4)= '.xml')
请把双引号改成单引号。
而且代码格式比较乱,最好整理下。
[解决办法]
一楼说的
还有就是检查一下是不是缺少;号