📄 frmchart.frm
字号:
VERSION 5.00
Begin VB.Form frmChart
Caption = "历史数据曲线窗口"
ClientHeight = 5520
ClientLeft = 45
ClientTop = 330
ClientWidth = 7500
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 5520
ScaleWidth = 7500
Begin VB.TextBox Text2
Height = 264
Left = 880
TabIndex = 11
Text = "1"
Top = 4540
Width = 372
End
Begin VB.OptionButton optPiCi1
Caption = "1#批次"
Height = 252
Left = 2640
TabIndex = 8
Top = 4680
Width = 852
End
Begin VB.OptionButton optPiCi2
Caption = "2#批次"
Height = 252
Left = 4080
TabIndex = 7
Top = 4680
Width = 972
End
Begin VB.OptionButton optPiCi3
Caption = "3#批次"
Height = 252
Left = 5880
TabIndex = 6
Top = 4680
Width = 852
End
Begin VB.TextBox Text1
Height = 264
Left = 360
Locked = -1 'True
TabIndex = 5
Text = "1"
Top = 4150
Width = 852
End
Begin VB.OptionButton opt3
Caption = "3#连续"
Height = 252
Left = 5880
TabIndex = 3
Top = 4320
Width = 852
End
Begin VB.OptionButton opt2
Caption = "2#连续"
Height = 252
Left = 4080
TabIndex = 2
Top = 4320
Width = 972
End
Begin VB.OptionButton opt1
Caption = "1#连续"
Height = 252
Left = 2640
TabIndex = 1
Top = 4320
Width = 852
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "D:\ylg2\ylg_data\lsjl.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 372
Left = 480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "continous1"
Top = 4800
Visible = 0 'False
Width = 1452
End
Begin VB.PictureBox pic
AutoRedraw = -1 'True
BackColor = &H00000000&
Height = 3372
Left = 120
ScaleHeight = 3315
ScaleWidth = 7035
TabIndex = 0
Top = 720
Width = 7092
End
Begin VB.Label Label2
Caption = "每次移动 条记录"
Height = 252
Left = 120
TabIndex = 10
Top = 4560
Width = 1812
End
Begin VB.Label Label1
Caption = "第 条记录"
Height = 252
Left = 120
TabIndex = 9
Top = 4200
Width = 1812
End
Begin VB.Label lbl
Height = 492
Left = 120
TabIndex = 4
Top = 120
Width = 7212
End
End
Attribute VB_Name = "frmChart"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private NN, i As Integer
Private fyfWenDu() As Single
Private jlgYeWei() As Single
Private tlfKaiDu() As Single
Private yjaLiuLiang() As Single
Private lqysWenDu() As Single
Private AA As Integer
Private Sub Form_Load()
Width = Screen.Width - dataviewfrm.Width - dataviewfrm.Left
Left = dataviewfrm.Left + dataviewfrm.Width
Top = baojingfrm.Top + baojingfrm.Height
Height = Screen.Height - baojingfrm.Top - baojingfrm.Height
AA = 1
NN = 50
End Sub
Private Sub opt1_Click()
With Data1
.RecordSource = "continous1"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Private Sub opt2_Click()
With Data1
.RecordSource = "continous2"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Private Sub opt3_Click()
With Data1
.RecordSource = "continous3"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Public Sub ReadDataAndDrawChart()
On Error Resume Next
ReDim fyfWenDu(NN)
ReDim jlgYeWei(NN)
ReDim deltajlgYeWei(NN)
ReDim tlfKaiDu(NN)
ReDim yjaLiuLiang(NN)
ReDim lqysWenDu(NN)
With Data1.Recordset
lbl.Caption = CStr(.Fields("riqi")) + " " + _
CStr(.Fields("currenttime")) + " 釜温度 " + _
CStr(Format(.Fields("fyfwendu"), "0.0")) + " 一甲胺流量 " + _
CStr(Format(.Fields("yjaliuliang"), "0.0")) + " 阀开度 " + _
CStr(Format(.Fields("tlfkaidu"), "0.0")) + " 冷却温度 " + _
CStr(Format(.Fields("lqyswendu"), "0.0")) + " " + _
"计量罐液位 " + CStr(Format(.Fields("jlgyewei"), "0.0"))
For i = 1 To NN
fyfWenDu(i) = .Fields("fyfwendu")
jlgYeWei(i) = .Fields("jlgyewei")
tlfKaiDu(i) = .Fields("tlfkaidu")
yjaLiuLiang(i) = .Fields("yjaliuliang")
lqysWenDu(i) = .Fields("lqyswendu")
.MoveNext
Next
For i = 1 To NN - AA
.MovePrevious
Next
End With
pic.Cls
For i = 1 To NN - 1
pic.Scale (0, 0)-(NN, -35)
pic.Line (i, fyfWenDu(i))-(i + 1, fyfWenDu(i + 1)), QBColor(fyfWenDu_Color)
pic.Line (0, -12)-(50, -12), fyfWenDuSheDing_Color
pic.Scale (0, 500)-(NN, 0)
pic.Line (i, 500 - jlgYeWei(i))-(i + 1, 500 - jlgYeWei(i + 1)), QBColor(jlgYeWei_Color)
pic.Scale (0, 100)-(NN, 0)
pic.Line (i, tlfKaiDu(i))-(i + 1, tlfKaiDu(i + 1)), QBColor(tlfaKaiDu_Color)
pic.Scale (0, 800)-(NN, 0)
pic.Line (i, yjaLiuLiang(i))-(i + 1, yjaLiuLiang(i + 1)), QBColor(yjaLiuLiang_Color)
pic.Scale (0, -20)-(NN, -40)
pic.Line (i, lqysWenDu(i))-(i + 1, lqysWenDu(i + 1)), QBColor(lqysWenDu_Color)
Next
End Sub
Private Sub optPiCi1_Click()
With Data1
.RecordSource = "detaills1"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Private Sub optPiCi2_Click()
With Data1
.RecordSource = "detaills2"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Private Sub optPiCi3_Click()
With Data1
.RecordSource = "detaills3"
.Refresh
.Recordset.MoveFirst
End With
End Sub
Private Sub pic_Click()
pic.Scale (0, 0)-(NN, -35)
End Sub
Private Sub pic_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyRight Then
AA = Abs(AA)
Call ReadDataAndDrawChart
Text1.Text = CStr(CInt(Text1.Text) + AA)
End If
If KeyCode = vbKeyLeft Then
AA = -Abs(AA)
Call ReadDataAndDrawChart
Text1.Text = CStr(CInt(Text1.Text) + AA)
End If
If KeyCode = vbKeyEscape Then Unload Me
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyReturn Then
Dim II As Integer
With Data1.Recordset
.MoveFirst
For II = 1 To CInt(Text1.Text)
.MoveNext
Next
End With
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyReturn Then AA = CInt(Text2.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -