7,765
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Dim PlotDataFilename As String
PlotDataFilename = "D:\kk\abc.txt"
Call PlotTodayDataCurve(PlotDataFilename)
End Sub
Private Sub Command1_Click()
Dim PlotDataFilename As String
PlotDataFilename = "D:\kk\abc.txt"
Call PlotTodayDataCurve(PlotDataFilename)
End Sub
Private Sub Form_Load()
Pict.DrawWidth = 1
Me.Top = 0
Me.Left = 0
Me.Width = Screen.Width
Me.Height = Screen.Height - 500
Pict.Top = 200
Pict.Left = 200
Pict.Width = Me.Width - 500
Pict.Height = Me.Height - 1300
Cls
End Sub
Public Function PlotTodayDataCurve(sFile As String)
PlotTodayCurveForm.Pict.Cls
Dim xx1(1440) As String
Dim xx2 As String
'Dim sFile As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim shujuchd As Integer
i = 0
xx2 = ""
PlotTodayCurveForm.Print sFile
Open sFile For Input As #33
Do While Not EOF(33)
i = i + 1
xx1(i) = ""
Input #33, xx1(i)
xx2 = xx2 + xx1(i)
Loop
Close 33#
shujuchd = i
'测试数据通道数
Dim length1 As Integer
Dim length2 As Integer
length2 = 1
length1 = Len(xx1(1))
For i = 1 To length1
If Mid$(xx1(1), i, 1) = " " Then
length2 = length2 + 1
End If
Next i
Dim xx3(1440, 6) As String
Dim xx4(1440, 6) As Double
Dim xx31 As Integer
Dim xx32 As Integer
xx37 = 0
j = 1
For i = 1 To shujuchd
xx31 = Len(xx1(i))
For k = 1 To xx31
If k = xx31 Then
xx3(i, j) = Mid$(xx1(i), xx37 + 1, k - xx37)
GoTo loop1
End If
If Mid$(xx1(i), k, 1) = " " Then
xx3(i, j) = Mid$(xx1(i), xx37 + 1, k - xx37 - 1)
xx37 = k
j = j + 1
End If
Next k
loop1:
xx37 = 0
j = 1
Next i
Dim xmax(6) As Double
Dim xmin(6) As Double
For i = 1 To length2
For k = 1 To shujuchd
If xx3(k, i) <> "NULL" Then
xmax(i) = Val(xx3(k, i))
xmin(i) = Val(xx3(k, i))
GoTo loop6:
End If
Next k
loop6:
For j = 1 To shujuchd
If xx3(j, i) = "NULL" Then
xx4(j, i) = 9999
Else
xx4(j, i) = Val(xx3(j, i))
End If
' If j = 1 Then
' xmax(i) = xx4(j, i)
' xmin(i) = xx4(j, i)
' End If
If xx4(j, i) = 9999 Then
GoTo loop2:
End If
If xmax(i) < xx4(j, i) Then '求最大值
xmax(i) = xx4(j, i)
End If
If xmin(i) > xx4(j, i) Then '求最小值
xmin(i) = xx4(j, i)
End If
loop2:
Next j
Next i
'***************绘图***************************************
h2 = 0
i = 0
j = 1
k = 0
h1 = (PlotTodayCurveForm.Pict.Height - length2 * 120 - 350) / (length2 * 11)
While i < length2
h3 = h2 + i * 100 + 350
PlotTodayCurveForm.Pict.CurrentX = 100
PlotTodayCurveForm.Pict.CurrentY = h2 + i * 100 + 350
PlotTodayCurveForm.Pict.ForeColor = RGB(0, 0, 255)
PlotTodayCurveForm.Pict.Print Format(xmax(i + 1), "@@@@@@@@@") '打印最大值
PlotTodayCurveForm.Pict.CurrentX = 100
PlotTodayCurveForm.Pict.CurrentY = h2 + i * 100 + 350 + length2 * h1
PlotTodayCurveForm.Pict.ForeColor = RGB(255, 155, 0)
PlotTodayCurveForm.Pict.Print "第" + Str(i + 1) + " 通道" '打印通道数
While j < 12
'画横线
PlotTodayCurveForm.Pict.Line (1100, h2 + i * 100 + 350)-(PlotTodayCurveForm.Pict.Width - 300, h2 + i * 100 + 350), RGB(0, 230, 0)
j = j + 1
h2 = h2 + h1
Wend
PlotTodayCurveForm.Pict.CurrentX = 100
PlotTodayCurveForm.Pict.CurrentY = h2 - 1.5 * h1 + i * 100 + 350
PlotTodayCurveForm.Pict.ForeColor = RGB(0, 0, 255)
PlotTodayCurveForm.Pict.Print Format(xmin(i + 1), "@@@@@@@@@") '打印最小值
While k < Int(shujuchd / 60) + 1 '画竖线
PlotTodayCurveForm.Pict.Line ((PlotTodayCurveForm.Pict.Width - 1400) / Int(shujuchd / 60) * k + 1100, h3)-((PlotTodayCurveForm.Pict.Width - 1400) / Int(shujuchd / 60) * k + 1100, h2 + i * 100 + 350 - h1), RGB(0, 200, 200)
hh3 = (h2 + i * 100 + 350 - h1) - h3
PlotTodayCurveForm.Pict.CurrentX = (PlotTodayCurveForm.Pict.Width - 1400) / Int(shujuchd / 60) * k + 950
PlotTodayCurveForm.Pict.ForeColor = RGB(0, 0, 255)
PlotTodayCurveForm.Pict.Print k '打印小时数
k = k + 1
Wend
'画图
j31 = shougeshu + 1
HangShu2 = j1
j = 1
k = 0
i = i + 1
Wend
Dim xmaxmin(6) As Double
Dim xxa As Double
Dim xmaxmin1(6) As Double
xxa = hh3
For i = 1 To length2
xmaxmin(i) = xmax(i) - xmin(i)
If xmaxmin(i) = 0 Then
xmaxmin1(i) = 0
Else
xmaxmin1(i) = xxa / xmaxmin(i)
End If
For j = 1 To shujuchd
If j = shujuchd Then
GoTo loop5
End If
If xx4(j, i) = 9999 Or xx4(j + 1, i) = 9999 Then
GoTo loop5:
End If
'数据画线
PlotTodayCurveForm.Pict.DrawWidth = 2
PlotTodayCurveForm.Pict.Line (1100 + (PlotTodayCurveForm.Pict.Width - 1400) / shujuchd * (j - 1), xmaxmin1(i) * (xmax(i) - xx4(j, i)) + (i - 1) * (xxa + 100 + h1) + 350)-(1100 + (PlotTodayCurveForm.Pict.Width - 1400) / shujuchd * j, xmaxmin1(i) * (xmax(i) - xx4(j + 1, i)) + (i - 1) * (xxa + 100 + h1) + 350), RGB(250, 0, 0)
PlotTodayCurveForm.Pict.DrawWidth = 1
loop5:
Next j
Next i
'***************************************************************
End Function