'''
Dim dm As String '代码
Dim cn As Integer = 0 '预设导入个数
Dim dt As Date = Date.Now
Dim ltg As Double = Nothing '流通股
Dim count As Integer = Tables("沪深A股").rows.count '个数
Dim ddate As Date
Dim qsp As Double '前收盘
Dim spj As Double '收盘价
Dim y0 As Integer = Date.Today.Year '当前日的年
Dim m0 As Integer = Date.Today.Month
Dim dt0 As New Date(y0, m0, 1)
Dim dt00 As New Date(y0, m0, Date.DaysInMonth(y0, m0)) '获取本月的最后一天
For Each dr As DataRow In DataTables("沪深A股").DataRows
If dr.IsNull("代码") = False Then
dm = dr("股piao代码")
ltg = dr("流通股亿")
cn += 1 '个数
Application.DoEvents '代码即刻生效----耗时
Dim b As New SQLGroupTableBuilder("统计表1", "日线") '基础数据来自日线
b.C
b.Groups.AddDef("代码")
b.Groups.AddDef("名称")
b.Groups.AddDef("日期", DateGroupEnum.Year, "年") '根据日期按年分组
b.Groups.AddDef("日期", DateGroupEnum.Month, "月") '根据日期按月分组
b.Totals.AddDef("成交量")
b.Filter = "代码= '" & dm & "'and (日期 >= '" & dt0 & "' and 日期 <= '" & dt00 & "')" '当前月
b.Build
Tables("统计表1").DataTable.DataCols.Add("本月开始", GetType(Date))
Tables("统计表1").DataTable.DataCols.Add("本月结束", GetType(Date))
Tables("统计表1").DataTable.DataCols.Add("日期", GetType(Date))
Tables("统计表1").DataTable.DataCols.Add("涨跌幅", GetType(Double))
Tables("统计表1").DataTable.DataCols.Add("换手率", GetType(Double))
Tables("统计表1").DataTable.DataCols.Add("收盘价", GetType(Double))
Tables("统计表1").DataTable.DataCols.Add("前收盘", GetType(Double))
Tables("统计表1").StopRedraw
If Tables("统计表1").Current IsNot Nothing Then
Dim r As Row = Tables("统计表1").Current
r("本月开始") = dt0
r("本月结束") = dt00
Dim drs As List(Of DataRow)
drs = DataTables("日线").SQLSelect("代码 = '" & dm & "' And 日期 >= '" & dt0 & "' and 日期 <= '" & dt00 & "'", "", "日期")
If drs.Count > 0 Then
ddate = drs(drs.Count - 1)("日期")
qsp = drs(0)("前收盘")
spj = drs(drs.Count - 1)("收盘价")
r("日期") = ddate
r("涨跌幅") = (spj - qsp) / qsp * 100
r("收盘价") = spj
r("前收盘") = qsp
r("换手率") = r("成交量") / (ltg * 1000000)
End If
End If
Tables("统计表1").ResumeRedraw
'MainTable = Tables("统计表1")
’更新月线数据,删除月线表的本月数据
DataTables("股piao月线").sqlDeleteFor("代码= '" & dm & "' and 日期 > '" & dt0 & "' " ) '删除月线的本月数据,因为可能不是本月最后1日的收盘数据
DataTables("股piao月线").RemoveFor("代码= '" & dm & "' and 日期 > '" & dt0 & "' " )
End If
Tables("统计表1").DataTable.DataRows.Clear '清除且保存
GC.Collect '释放内存
'将统计表数据导入到月线表
......
Next