这里会有所帮助!?
Private Function getdaodata() As Long 'dao数组方式,与ado的DataMember方式无区别
Dim wdaodata() As Variant '应用此方式时,此变量要声明为模块级
Dim wlng As Long
Dim wstr As String
Dim sql As String
Dim xstr(4) As String
Dim ystr(3) As String
Dim Titlestr As String
Dim i As Long
Dim NewDyn As DAO.Recordset
Dim OpenWs As DAO.Workspace
Dim OpenDB As DAO.Database
Set OpenWs = DBEngine.Workspaces(0)
sql = "SELECT tableMSChart.* "
sql = sql + "FROM tableMSChart ORDER BY tableMSChart.datewt;"
Set OpenDB = OpenWs.OpenDatabase(App.Path & "\db1forMSChart.mdb")
Set NewDyn = OpenDB.OpenRecordset(sql)
NewDyn.MoveLast
NewDyn.MoveFirst
If NewDyn.RecordCount = 0 Then
MsgBox "请在数据库中输入数据!", vbCritical
Exit Function
End If
'语法
'ReDim [Preserve] varname(subscripts) [As type] [, varname(subscripts) [As type]] . . .
'subscripts 必需的。 语法:[lower To] upper [,[lower To] upper] . . .
wlng = NewDyn.RecordCount
ReDim wdaodata(wlng, 6) '在过程级别中使用,用于为动态数组变量重新分配存储空间。
With MSChart1
.RowCount = NewDyn.RecordCount
NewDyn.MoveFirst
For i = 1 To NewDyn.RecordCount
.Row = i
'将日期值转换为文本值,才可自动作标签处理
wdaodata(i, 1) = "RowLabel " & NewDyn.Fields("datewt") ' Labels
wdaodata(i, 2) = NewDyn.Fields("shdulla") 'Series1
wdaodata(i, 3) = NewDyn.Fields("shdullb") 'Series2
wdaodata(i, 4) = NewDyn.Fields("shdullc") 'Series3
wdaodata(i, 5) = NewDyn.Fields("shdulld") 'Series4
wdaodata(i, 6) = NewDyn.Fields("shmarkup") 'Series5
NewDyn.MoveNext
Next i
NewDyn.Close
'列标要最后才加上去,不能在徇环语句内,否则徇环终值较大时,数据及标签会重复绘在列标区域
sql = "SELECT tableMSChartcode.* FROM tableMSChartcode; "
Set NewDyn = OpenDB.OpenRecordset(sql)
wstr = Chr(39) & Chr(-14123) & Chr(-14630) & Chr(58) & Chr(39) ' "'日期:'"
xstr(0) = Chr(-16165) & Chr(-17210) & Chr(-17233) & Chr(-19473) '累计集筹
xstr(1) = "5" & Chr(-13076) & Chr(-11578) & Chr(-18769) '5天移动
xstr(2) = "10" & Chr(-13076) & Chr(-11578) & Chr(-18769) '10天移动
xstr(3) = "15" & Chr(-13076) & Chr(-11578) & Chr(-18769) '15天移动
xstr(4) = Chr(-16165) & Chr(-17210) & Chr(-10809) & Chr(-18439) '累计涨幅
With NewDyn
ystr(0) = Nz(.Fields(2).Value) 'shdulla倍数shscale
ystr(1) = Nz(.Fields(3).Value) '名shdulla
ystr(2) = Nz(.Fields(4).Value) 'shmarkup的倍数
ystr(3) = Nz(.Fields(5).Value) 'shdullb的倍数
End With
Titlestr = CStr(NewDyn.Fields(0).Value) & " " & NewDyn.Fields(1).Value '代码'名称
NewDyn.Close
If ystr(3) <> "" Then
xstr(1) = "5" & Chr(-13076) & Chr(-11578) & Chr(-18769) & "×" & ystr(3) '5天移动
xstr(2) = "10" & Chr(-13076) & Chr(-11578) & Chr(-18769) & "×" & ystr(3) '10天移动
xstr(3) = "15" & Chr(-13076) & Chr(-11578) & Chr(-18769) & "×" & ystr(3) '15天移动
End If
If ystr(2) <> "" Then
xstr(4) = Chr(-16165) & Chr(-17210) & Chr(-10809) & Chr(-18439) & "×" & ystr(2) '累计涨幅
End If
If ystr(0) <> "" Then
xstr(0) = Chr(-16165) & Chr(-17210) & Chr(-17233) & Chr(-19473) & "×" & ystr(0) '累计集筹
End If
wdaodata(1, 2) = xstr(0) ' Labels1
wdaodata(1, 3) = xstr(1) ' Labels2
wdaodata(1, 4) = xstr(2) ' Labels3
wdaodata(1, 5) = xstr(3) ' Labels4
wdaodata(1, 6) = xstr(4) ' Labels5
.ChartData = wdaodata
End With
OpenDB.Close
OpenWs.Close
Set OpenDB = Nothing
Set OpenWs = Nothing
Me.MSChart1.Title.Text = Titlestr
With MSChart1.Title.VtFont
.Name = "Algerian"
.Style = VtFontStyleBold
.Effect = VtFontEffectUnderline
.Size = 14
.VtColor.Set 255, 0, 255
End With
getdaodata = wlng
End Function