| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 405 人关注过本帖
标题:请问以下这段代码中红色标注部分有什么作用呢?
只看楼主 加入收藏
shenlong2006
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-11-2
结帖率:0
收藏
 问题点数:0 回复次数:2 
请问以下这段代码中红色标注部分有什么作用呢?
我把红色部分的代码删除后,按F8单步运行能得到正确结果,但是直接点运行时却只能得到重复的数据,很疑惑,高手帮忙解释一下吧!
把实例也传上来了
Sub a()
Dim ie1 As Object, dmt As Object, r As Object, i As Long, j As Long, n As Long, p As Long
'Load UserForm1
'UserForm1.Show 0
On Error Resume Next
[a1].CurrentRegion.Offset(1).Clear
Cells.NumberFormat = "@"
Set ie1 = UserForm1.WebBrowser1
With ie1
  .Navigate "http://stock. '网址
  Do Until .ReadyState = 4 And InStr(.Document.body.innertext, "行情 资讯 股吧") > 0
    DoEvents
  Loop
  Set dmt = .Document
End With
Set r = dmt.All.tags("table")(1).Rows
For i = 0 To r.Length - 1
   For j = 0 To r(i).Cells.Length - 1
       Cells(i + 2, j + 1) = r(i).Cells(j).innertext
   Next
Next
Set dmt = Nothing
Set r = Nothing
For p = 2 To 23
   With ie1
      .Navigate "javascript:myNiceTable.goPage(" & p & ");"
      Do Until Val(.Document.All.tags("table")(1).Rows(0).Cells(0).innertext) = (p - 1) * 50 + 1
        DoEvents
      Loop
      Set dmt = .Document
   End With
   Set r = dmt.All.tags("table")(1).Rows
   n = [a65536].End(3).Row + 1
   For i = 0 To r.Length - 1
      For j = 0 To r(i).Cells.Length - 1
          Cells(i + n, j + 1) = r(i).Cells(j).innertext
      Next
   Next
   Set dmt = Nothing
   Set r = Nothing
Next
Set ie1 = Nothing
[a1].CurrentRegion.Columns.AutoFit
MsgBox "ok!"
End Sub
搜索更多相关主题的帖子: Object 数据 
2012-04-05 21:30
shenlong2006
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-11-2
收藏
得分:0 
实例.rar (11 KB)
2012-04-05 21:31
苦寒
Rank: 2
等 级:论坛游民
帖 子:18
专家分:55
注 册:2012-3-22
收藏
得分:0 
当条件“Val(.Document.All.tags("table")(1).Rows(0).Cells(0).innertext) = (p - 1) * 50 + 1”成立时,继续执行后续的操作;否则执行DoEvents,向系统递交控制权。否则程序就像死机了一样。

2012-04-08 10:07
快速回复:请问以下这段代码中红色标注部分有什么作用呢?
数据加载中...
 
   



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

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