The code used to plot the graph data is as follows. If I insert an Exit sub at the beginning of this subroutine to bypass the graph, no memory usage occurs. I have also tried using the 'DoEvents' commad at the end of the subroutine to ensure windows clean-up but that did not help. Code...
Private Sub objHandleEvents_UpdateMeasurementGraph(boolXAxisAuto As Boolean, boolYAxisAuto As Boolean, _
dblXMinimum As Double, dblXMaximum As Double, _
dblYMinimum As Double, dblYMaximum As Double, _
intLineStyle As Integer, conLineColor As ColorConstants, _
intPointStyle As Integer, conPointColor As ColorConstants, _
arGraphData As Variant, boolClear As Boolean)
'*****************************
'* Set generic error handler *
'*****************************
On Error GoTo HandleError
'*************************
'* Variable Declarations *
'*************************
Dim intCounter As Integer
Dim boolRunTimeError As Boolean
Dim objXAxes As CWAxis
Dim objYAxes As CWAxis
Dim objPlot As CWPlot
Dim arGraphXData() As Variant
Dim arGraphYData() As Variant
'*******************
'* Clear the graph *
'*******************
If boolClear = True Then
gphMeasurementGraph.ClearData
End If
'***************************
'* Create Object Instances *
'***************************
Set objXAxes = gphMeasurementGraph.Axes.Item(1)
Set objYAxes = gphMeasurementGraph.Axes.Item(2)
Set objPlot = gphMeasurementGraph.Plots.Add
'**************************
'* Make the graph visible *
'**************************
gphMeasurementGraph.Visible = True
'*************************
'* Setting up the X-Axis *
'*************************
objXAxes.Ticks.MajorGrid = True
objXAxes.Ticks.MajorGridColor = vbWhite
objXAxes.AutoScale = boolXAxisAuto
If (Not objXAxes.AutoScale) Then
objXAxes.SetMinMax dblXMinimum, dblXMaximum
End If
'*************************
'* Setting up the Y-Axis *
'*************************
objYAxes.Ticks.MajorGrid = True
objYAxes.Ticks.MajorGridColor = vbWhite
objYAxes.AutoScale = boolYAxisAuto
If (Not objYAxes.AutoScale) Then
objYAxes.SetMinMax dblYMinimum, dblYMaximum
End If
'***********************
'* Setting up the Plot *
'***********************
objPlot.LineStyle = intLineStyle
objPlot.LineColor = conLineColor
objPlot.LineWidth = 3
objPlot.PointStyle = intPointStyle
objPlot.PointColor = conPointColor
'******************
'* Chart the data *
'******************
ReDim arGraphXData(LBound(arGraphData) To UBound(arGraphData))
ReDim arGraphYData(LBound(arGraphData) To UBound(arGraphData))
For intCounter = LBound(arGraphData) To UBound(arGraphData)
arGraphXData(intCounter) = arGraphData(intCounter, 0)
arGraphYData(intCounter) = arGraphData(intCounter, 1)
Next intCounter
objPlot.ChartXvsY arGraphXData, arGraphYData
'Tried "DoEvents" Here
'****************************
'* Destroy object instances *
'****************************
Set objXAxes = Nothing
Set objYAxes = Nothing
Set objPlot = Nothing
'Tried "DoEvents" Here
ExitHere:
If (boolRunTimeError) Then
Unload Me
Else
Exit Sub
End If
HandleError:
Select Case Err.Number
Case Else
boolRunTimeError = True
Call HandleErrors(Err.Number, Err.Description, "objHandleEvents UpdateMeasurementGraph Sub")
End Select
Resume ExitHere
End Sub