还有一个问题,可以追加分的,请帮一下var
doc:IHTMLDocument3;
tables:IHTMLElementCollection;
Table1 :HTMLTable;
Row :HTMLTableRow;
Cell : HTMLTableCell ;
i,j:integer;
begin
doc:=WebBrowser1.Document as IHTMLDocument3;//呵呵,这儿可不是IHTMLDocument2
tables:=doc.getElementsByTagName('table');
For i:=1 To Table1.rows.length - 1 do
begin
row:=Table1.rows(i);
.............为什么在编译时, row:=Table1.rows(i); 总是出错,到底错在那里呢?
另外,还想请教一下
VB 语句有: For Each Table1 In Tables我在DEPHI 应该怎样写这个呢?
doc:IHTMLDocument3;
tables:IHTMLElementCollection;
Table1 :HTMLTable;
Row :HTMLTableRow;
Cell : HTMLTableCell ;
i,j:integer;
begin
doc:=WebBrowser1.Document as IHTMLDocument3;//呵呵,这儿可不是IHTMLDocument2
tables:=doc.getElementsByTagName('table');
For i:=1 To Table1.rows.length - 1 do
begin
row:=Table1.rows(i);
.............为什么在编译时, row:=Table1.rows(i); 总是出错,到底错在那里呢?
另外,还想请教一下
VB 语句有: For Each Table1 In Tables我在DEPHI 应该怎样写这个呢?
解决方案 »
- rmreport 查询数据库后怎么输出记录数量
- image滚动问题
- 最后17分﹐请问一个delphi小问题…….
- 只选择时间,用DateTimePicker控件可以吗?另外,为什么时间是17:00,显示的却是5:00呢?
- 执行多条sql语句如何保证完整性。
- activeform开发问题,如何在activeform中加入自己定义的属性,我想让别的程序传递给activeform一个参数,我用这个参数控制显示页
- 问一个小问题?大家不要笑呀!
- 请问SpinEdit中的OnChange、OnClick、OnEnter有什么区别和联系???
- 为什么一台电脑上同时装两块内置MODEM卡不能成功???
- 散分
- 怎样不显示dbgrid中的某行?(在线等待)
- 为什么读取excel有个别数据读不出来?
doc:IHTMLDocument3;
tables:IHTMLElementCollection;
Table1 :HTMLTable;
Row :HTMLTableRow;
Cell : HTMLTableCell ;
i,j:integer;
begin
doc:=WebBrowser1.Document as IHTMLDocument3;//呵呵,这儿可不是IHTMLDocument2
tables:=doc.getElementsByTagName('table');
For i:=1 To Table1.rows.length - 1 do
begin
row:= Table1.rows.item(i, i) as HTMLTableRow; //这样可以,不知道能否得到正确结果
end;
end;Delphi中没有类似VB中For Each Table1 In Tables的语句
用循环实现吧
var
doc:IHTMLDocument3;
tables:IHTMLElementCollection;
Table1 :HTMLTable;
Row :HTMLTableRow;
Cell : HTMLTableCell ;
i,j:integer;
begin
doc:=WebBrowser1.Document as IHTMLDocument3;//呵呵,这儿可不是IHTMLDocument2
Tables:= doc.getElementsByTagName('table');
if Tables = nil then
exit;
table1 := Tables.item(0,0) as HTMLTable;
if table1 = nil then
exit;
For i:=0 To Table1.rows.length - 1 do
begin
if Table1.rows.item(i,i) = nil then
continue;
row:= Table1.rows.item(i,i) as HTMLTableRow;
for j := 0 to row.cells.length -1 do
begin
if row.cells.item(j,j) = nil then
continue;
Cell := row.cells.item(j,j) as HTMLTableCell;
//Memo1.lines.Add(Cell.innerText);
end;
end;
end;