Example: ChartMode Manual
To use this example, create a form with a trend object and a time, both with the default names. Paste the code below into the code window.
Option Explicit Private Sub Form_Load() Dim Ps As Pens Set Ps = TrendX1.Pens Ps.Add "Tag0", "Temp 1", "Deg F", 0, 100 Ps.Add "Tag1", "Pump 1", "Volts", 0, 100 Trend1.ChartMode = rstManual Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer() ' This routine is called by Timer1 ' Notice that this routine would have to be called ' every time the interval is up, regardless of how ' much the data has changed. ' If the trend includes pens that do not change often, ' this may be inefficient. Dim Var As Variant Dim vararray(1 To 2) As Variant Dim i As Integer For i = 1 To 2 ' For a real application, vararray(i) would be ' set to real data. ' For example, ' vararray(i) = txtPLCData(i).text ' where txtPLCData is an array of text fields ' being fed PLC data via DDE. vararray(i) = i * 10 * Rnd Next Var = vararray Trend1.NewData Now, Timer1.Interval, Var End Sub
Provide Feedback