📄 frmchart.frm
字号:
VERSION 5.00
Begin VB.Form frmChart
Caption = "Form1"
ClientHeight = 6825
ClientLeft = 45
ClientTop = 330
ClientWidth = 9510
LinkTopic = "Form1"
ScaleHeight = 6825
ScaleWidth = 9510
StartUpPosition = 3 'Windows Default
Begin VB.HScrollBar HScroll1
Height = 252
LargeChange = 10
Left = 2760
SmallChange = 2
TabIndex = 4
Top = 5160
Width = 3612
End
Begin VB.OptionButton opt3
Caption = "3#"
Height = 252
Left = 5400
TabIndex = 3
Top = 5520
Width = 1092
End
Begin VB.OptionButton opt2
Caption = "2#"
Height = 252
Left = 3600
TabIndex = 2
Top = 5520
Width = 1452
End
Begin VB.OptionButton opt1
Caption = "1#"
Height = 252
Left = 2160
TabIndex = 1
Top = 5520
Width = 1092
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "D:\ylg\ylg_data\lsjl.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 372
Left = 2760
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "continous1"
Top = 6120
Width = 3612
End
Begin VB.PictureBox pic
Height = 4092
Left = 120
ScaleHeight = 4035
ScaleWidth = 9195
TabIndex = 0
Top = 360
Width = 9252
End
Begin VB.Label lbl
Caption = "Label1"
Height = 252
Left = 480
TabIndex = 5
Top = 4680
Width = 6972
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
Dim fyfWenDu(), jlgYeWei(), deltajlgYeWei() As Single
Private oldMark As Variant
Private Sub Form_Load()
NN = 50
End Sub
Private Sub HScroll1_Change()
On Error Resume Next
lbl.Caption = CStr(Data1.Recordset.Fields("riqi")) + " " + CStr(Data1.Recordset.Fields("currenttime")) + " " + CStr(Format(Data1.Recordset.Fields("fyfwendu"), "0.0")) ' + " " + CStr(Format(deltajlgYeWei(i), "0.0"))
Call ReadDataAndDrawChart
End Sub
Private Sub opt1_Click()
With Data1
.Recordset.MoveFirst
.RecordSource = "continous1"
End With
HScroll1.Value = 0
End Sub
Private Sub opt2_Click()
With Data1
.Recordset.MoveFirst
.RecordSource = "continous2"
End With
HScroll1.Value = 0
End Sub
Private Sub opt3_Click()
With Data1
.Recordset.MoveFirst
.RecordSource = "continous3"
End With
HScroll1.Value = 0
End Sub
Public Sub ReadDataAndDrawChart()
On Error Resume Next
ReDim fyfWenDu(NN)
ReDim jlgYeWei(NN)
ReDim deltajlgYeWei(NN)
With Data1.Recordset
For i = 1 To NN
fyfWenDu(i) = .Fields("fyfwendu")
jlgYeWei(i) = .Fields("jlgyewei")
deltajlgYeWei(i) = jlgYeWei(i) - jlgYeWei(i - 1)
If deltajlgYeWei(i) < 0 Then deltajlgYeWei(i) = 0
.MoveNext
Next
For i = 1 To NN - 1
.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)), RGB(0, 0, 255)
pic.Line (0, -12)-(50, -12), RGB(0, 0, 255)
pic.Scale (0, 500)-(NN, 0)
pic.Line (i, jlgYeWei(i))-(i + 1, jlgYeWei(i + 1))
pic.Scale (0, 10)-(NN, -10)
pic.Line (i, deltajlgYeWei(i))-(i + 1, deltajlgYeWei(i + 1)), RGB(255, 0, 0)
Next
End Sub
Private Sub pic_Click()
pic.Scale (0, 0)-(NN, -35)
pic.Line (0, -12)-(50, -12), RGB(0, 0, 255)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -