示例:ChartMode Automatic

要使用本示例,请创建一个窗体,其中包含一个趋势对象、一个标记和两个按钮,均采用默认名称。将下面的代码粘贴到代码窗口中。这个示例还展示了 Value 属性的用法。
Option Explicit Dim pen1, pen2 As Pen Private Sub Form_Load() Dim Ps As Pens Set Ps = Trend1.Pens Set pen1 = Ps.Add("Tag0", "Temp 1", "Deg F", 0, 100) Set pen2 = Ps.Add("Tag1", "Pump 1", "Volts", 0, 100) Trend1.RefreshRate = 1000 Trend1.ChartMode = rstAutomatic End Sub Private Sub Temp1_Changed(newTemp1 As Long) ' This routine only has to run when Temp1 changes. ' The chart will reflect the new value on the next refresh. pen1.Value = newTemp1 End Sub Private Sub Pump1_Changed(newPump1 As Long) ' This routine only has to run when Pump1 changes. ' The chart will reflect the new value on the next refresh. pen2.Value = newPump1 End Sub ' Some buttons to make the graph change. Private Sub Command1_Click() Temp1_Changed (Rnd * 100) End Sub Private Sub Command2_Click() Pump1_Changed (Rnd * 100) End Sub Private Sub Trend1_RefreshRateExpired() Static n Label1.Caption = n & " points" n = n + 1 ' NOTE: The number of points actual stored is limited ' to the number on the screen, plus the number in the ' BufferSize property. End Sub
提供反馈
对本文档有问题或反馈吗? 请在这里提交您的反馈
Normal