从ACCESS数据库中读取数据并用MSChart绘制曲线

cy971596 2009-04-27 08:45:05
各位请帮我看看,这段程序不能显示曲线。。问题出在哪?
Sub drawing()
Dim Choice As String
Dim j As Byte
Dim s As Integer
Dim Values() As Byte
Dim Rs() As Byte
Dim d As Date
Dim Con As New Connection
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\tej.mdb"
Rs() = "select 温度 from 温度记录 Where DATEDIFF(d,取温时间,NOW())<4"
Text4.Text = Rs()
With MSChart1
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 50
MSChart1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = -10
MSChart1.ColumnCount = 1
MSChart1.RowCount = 48 '设置显示数据个数
MSChart1.Width = 300 * MSChart1.RowCount '设置像素
Values() = Rs()
MSChart1.ChartData = Values()

j = j + 1
If j > 48 Then
For s = 2 To 48
Values(s - 1) = Values(s)
MSChart1.Row = s - 1
MSChart1.ChartData = Values(s - 1)
Next
j = j - 1
End If

End With
End Sub


这幅帖子说不能给分啊。。我是新来的。。请多帮忙。 如果可以。以后有分了在补给各位
...全文
204 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
贝隆 2009-04-27
  • 打赏
  • 举报
回复
我觉得你出现了语法错误:
1、首先你没有查询记录集对象,怎么查询?
2、Rs是Byte型数组,怎么能这样赋值:Rs() = "select 温度 from 温度记录 Where DATEDIFF(d,取温时间,NOW()) <4" ?
3、Text4.Text = Rs(),这句也值得商榷,你到底要显示写什么?估计你得不到你要的东西。
4、后面的就先不说了。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧