Example: ChartMode Automatic
To use this example, create a form with a trend object, a label, and two buttons, all with the default names. Paste the code below into the code window. This example also shows how the Value property is used.
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
Provide Feedback