Dim web As New System.Windows.Forms.WebBrowser()
web.ScriptErrorsSuppressed = True
web.Navigate("http://youjia.chemcp.com/YuanYouJiaGe.asp")
Do Until web.ReadyState = 4
Application.DoEvents
Loop
Dim Cols() As String = { "名称","价格","涨跌额","涨跌幅","发布日期" }
Dim elems As object = web.Document.GetElementsByTagName("table")(5).GetElementsByTagName("tr")
Dim t As Table = Tables("国际市场原油价格表")
For i As Integer = 1 To elems.count-1
Dim tdelems As object = elems(i).GetElementsByTagName("td")
Dim fdr As DataRow = t.DataTable.Find("名称 = '" & tdelems(0).Innertext & "' and 发布日期 = #" & tdelems(4).Innertext & "#")
If fdr Is Nothing Then
fdr = t.DataTable.AddNew
End If
For j As Integer = 0 To Cols.length-1
If t.Cols(j).IsNumeric Then
fdr(Cols(j)) = val(tdelems(j).Innertext.replace("↓", "").replace("↑", "").replace("%", ""))
fdr("更新时间") = Date.Now
Else
fdr(Cols(j)) = tdelems(j).Innertext
fdr("更新时间") = Date.Now
End If
Next
Next
t.save
Tables("国际市场原油价格表").Sort = "发布日期 DESC"
MessageBox.show("数据更新完毕!")
发布后的项目点击该按钮有如下提示,可能是什么问题?
.NET Framework 版本:2.0.50727.6387
Foxtable 版本:2016.7.29.1
错误所在事件:窗口,国际市场原油价格窗口,Button1,Click
详细错误信息:
“5”的值对于“index”无效。“index”应介于 0 和 1 之间。
参数名: index