原来程序可以自动画图
Private Sub GraphTest()
Dim i As Integer
Dim colGraph As New Collection
Do
Randomize
colGraph.Add Int(Rnd * 1000)
Call myGraph.DrawGraph(colGraph)
tmrWait.Enabled = True
Do While tmrWait.Enabled = True
DoEvents
Loop
Loop
End Sub
我改后的程序如下:
Private Sub GraphTest()
Dim i As Integer
Dim colGraph As New Collection
Dim a As aaa
Set a = New aaa
Adodc1.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\tiph.mdb;Persist Security Info=False"
Adodc1.RecordSource = "Select * From 钛平衡计算 order by 日期"
Adodc1.CommandType = adCmdText
Adodc1.Refresh
tmrWait.Enabled = True
Do While tmrWait.Enabled = True
DoEvents
Loop
Loop
End Sub
出现“用户定义类型未定义”错误。
附上DrawGraph函数源码:
Public Function DrawGraph(ByVal colGraphValues As Collection)
Dim i As Long
Dim IntX(1) As Integer
Dim IntY(1) As Integer
Dim intYScale As Integer
' 正确则继续
On Local Error Resume Next
With Graph
' 清除
.Cls
' 计算比例
intYScale = .ScaleHeight / MaxScaleValue
' Keep the collection inside the bounarys of our graph
Do While colGraphValues.Count > Int(.Width / 100 / 2) 'ADDED /2
' 删除过去记录
colGraphValues.Remove 1
Loop
' Set x-cord
.CurrentX = 0
' Draw all y- scales exept the zero
For i = 0 To 4
' Draw scales
.CurrentY = Int(.ScaleHeight / 4) * i
Graph.Print MaxScaleValue - Int(MaxScaleValue * i / 4)
Dim colGraph As Collection
dim a as aaa
set colGraph = new Collection
set a = new aaa
a。时间 = Adodc1.Recordset.Fields("时间")
a。流量 = Adodc1.Recordset.Fields("流量")