请问这几个过程有没有问题?
在论坛学得一程序,想捉猫画虎,添加了一个数据的读取,可实现不了。能否帮助指点一下,Option Explicit
Private Type 数据结构类型
时间 As Date
值 As Double
X As Double
Y As Double
End Type
Dim 数据(1 To 50) As 数据结构类型
Dim data8(1 To 50) As 数据结构类型 '自己添加的
Dim Max值 As Double
Dim Min值 As Double
Dim interdata0 As Double '自己添加的存储新数据
Dim interdata8 As Double '自己添加的存储新数据
Dim datagate0 As Boolean '自己添加的用于判断数据更新
Dim datagate8 As Boolean '自己添加的用于判断数据更新
Dim 高间格 As Double, 宽间格 As Double 'Long
Public Sub ADDdata() '自己添加的过程用于将两组数据同步更新
Dim i As Integer
If datagate0 = True or datagate8=true Then '有任一组数据更新则全部重算,无更新的那一组前推,如都没更新,则本过程无实际代码执行
If datagate0 = True Then
For i = 2 To 50
数据(i - 1).值 = 数据(i).值
Next i
数据(50).值 = interdata0
else
For i = 2 To 50
数据(i - 1).值 = 数据(i).值
Next i
数据(50).值 = 数据(50).值
End If
If datagate8 = True Then
For i = 2 To 50
data8(i - 1).值 = data8(i).值
Next i
data8(50).值 = interdata8
Else
For i = 2 To 50
data8(i - 1).值 = data8(i).值
Next i
data8(50).值 = data8(50).值
End If
End If
datagate0 = False
datagate8 = False
End Sub
Public Sub MaxMin值() '找出最大值,最小值,添加在两组数中找
Dim i As Integer
Max值 = 1.5 '数据(1).值
Min值 = 1.1 '数据(1).值
For i = 2 To 50
If Max值 < 数据(i).值 Then
Max值 = 数据(i).值
End If
If Min值 > 数据(i).值 Then
Min值 = 数据(i).值
End If
Next i
For i = 2 To 50
If Max值 < data8(i).值 Then
Max值 = data8(i).值
End If
If Min值 > data8(i).值 Then
Min值 = data8(i).值
End If
Next i
End Sub
Public Sub Cls数据()
Dim i As Integer
For i = 1 To 50
数据(i).值 = 0
数据(i).时间 = #12:00:00 AM#
data8(i).值 = 0
data8(i).时间 = #12:00:00 AM#
Next i
End Sub
Public Sub 读数据(cs As String)
Dim fr As Integer
fr = FreeFile
Dim d As String
Dim dd As String '自己添加的
Dim fj() As String
Dim j As String
Open cs For Input Access Read As #fr
Do While Not EOF(fr)
Line Input #fr, j
If InStr(1, j, ";") > 0 Then
fj = Split(j, ";")
If d <> fj(0) Or dd <> fj(1) then '自己添加一个条件
d = fj(0)
dd = fj(1)
interdata0 = sdbl(fj(1))
datagate0 = True
End If
End If
Loop
Close fr
End Sub
Public Sub readdata8(cs8 As String) '自己添加的读取另一文件数据
Dim fr8 As Integer
fr8 = FreeFile
Dim d8 As String
Dim dd8 As String
Dim fj8() As String
Dim j8 As String
Open cs8 For Input Access Read As #fr8
Do While Not EOF(fr8)
Line Input #fr8, j8
If InStr(1, j8, ";") > 0 Then
fj8 = Split(j8, ";")
If d8 <> fj8(0) Or dd8 <> fj8(1) then
d8 = fj8(0)
dd8 = fj8(1)
interdata8 = sdbl(fj8(1))
datagate8 = True
End If
End If
Loop
Close fr8
End Sub
.....................
Private Sub Timer1_Timer()
Call Cls数据 '清掉前面的代码
Call 读数据("E:\333.CSV") '打开第一个文件,读数据
Call readdata8("E:\888.CSV") '打开第二个文件,读数据
Call ADDdata
Call 绘折线图(Picture1) '绘制折线图
' Stop
End Sub