VB 错误,请高手调试

[复制链接]
查看11 | 回复1 | 2009-3-12 09:25:41 | 显示全部楼层 |阅读模式
一个窗体form1,一个MSChart控件,引用DAO,一个按钮command
模块中的代码:
Public values() As Single
Public numpoints As Integer
Public Sub LoadData()

Dim db As Database, qdef As QueryDef, rs As Recordset, dbname As String, i As Integer

dbname = App.Path

If Right$(dbname, 1)"\" Then

dbname = dbname & "\"

End If

dbname = dbname & "data.mdb"

Set db = OpenDatabase(dbname)

Set qdef = db.CreateQueryDef("", "SELECT year,value FROM yearlyvalues")

Set rs = qdef.OpenRecordset(dbOpenSnapshot)

rs.MoveLast

numpoints = rs.RecordCount

ReDim values(1 To numpoints, 1 To 2)

rs.MoveFirst

For i = 1 To numpoints

values(i, 1) = Format$(rs!Year, "yyyy")

values(i, 2) = rs!Value

rs.MoveNext

Next i

rs.Close

db.Close
End Sub
Public Sub MakeData()
Dim the_year As Data, the_value As Single

dbname = App.Path & "\data.mdb"

Set db = OpenDatabase(dbname)

SQL = "DELETE FROM Yearlyvalues"

db.Execute SQL

the_year = #1/1/1960#

the_value = 1000



For i = 1 To 38

SQL = "INSERT INTO Yearlyvalues VALUES(#" & Format$(the_year) & "#," & Format$(the_value) & ")"

db.Execute SQL

the_year = DateAdd("yyyy", 1 + Rnd(i) * 2, the_year)

the_value = the_value + Rnd(i) * 2

Next i

db.Close
End Sub
窗体加载代码:
Private Sub Form_Load()

LoadData

If numpoints = 0 Then

MsgBox ("hahah")

End If



chart1.chartType = VtChChartType2dXY

chart1.RowCount = numpoints

chart1.ColumnCount = 2

chart1.ChartData = values
End Sub
按钮单击代码:
Private Sub Command1_Click()

MakeData

LoadData



chart1.chartType = VtChChartType2dXY

chart1.RowCount = numpoints

chart1.ColumnCount = 2

chart1.ChartData = values
End Sub
出现错误:

实时错误,3061,

参数不足,期待是1。

回复

使用道具 举报

千问 | 2009-3-12 09:25:41 | 显示全部楼层
问别人出错问题时候,最好加上哪一行出错了,方便自己也方便别人。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行