'''
Dim sstr As String = "" '错误记录
Dim dm,dm1 As String '沪深冠字
Dim _sr As String = Format(e.Form.Controls("DateTimePicker1").value , "yyyyMMdd") '起始日期=结束日期
Dim _zr As String = Format(e.Form.Controls("DateTimePicker1").value , "yyyyMMdd") '结束日期
Dim cn As Integer = 0 '预设导入股piao个数
Dim dt As Date = Date.Now
Dim str As String = "" '股piao名预设
Dim count As Integer = Tables("沪深A股").rows.count '股piao个数
DataTables("沪深A股").ResumeRedraw
Dim obj_down As New System.Net.WebClient()
DataTables("沪深A股").StopRedraw
For Each dr As DataRow In DataTables("沪深A股").DataRows '遍历行,根据代码获取数据,起始时间与结束时间相同,仅获取单日数据
If dr.IsNull("代码") = False Then
dm = dr("代码")
If dm >= 600000 Then
dm1 = "0" & dm '沪市
Else
dm1 = "1" & dm '深市
End If
End If
try
Dim data As String = obj_down.DownloadString("http://quotes.money.163.com/service/chddata.html?code=" & dm1 & "&start=" & _sr & "&end=" & _zr & "&fields=TCLOSE;HIGH;LOW;TOPEN;LCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP")
data = data.Replace(vblf,"").Replace("'","''")
Dim rs() As String = data.Split(vbcr)
str = dm
cn +=1 '股piao个数
'For i As Integer = 1 To rs.Length - 2 '首行是标题
Dim cs() As String = rs(1).Split(",")
If cs.Length = 15 Then
dr("日期") = cs(0)
dr("今日开盘") = cs(6)
dr("今日涨跌幅") = cs(9)
End If
'Next
Catch ex As Exception
sstr &= dm & "," '出错个数
End Try
Next
DataTables("沪深A股").ResumeRedraw
Dim tp As TimeSpan
tp = Date.Now - dt
e.Form.Controls("Label运行提示").text = "正在下载 " & cn & "/" & count & " 只股piao:" & vbcrlf & "耗时 " & tp.TotalSeconds