So I'm learning a little about class objects, and I defined my own class and wrote some code to set values and all that.
From what I understand, the way I have written my code below, the system doesnt actually create my class object BPFeature until the line
I might be wrong on that, but from what I've read thats the way I understand it to work.
So if thats when the object is created, I'm wondering, when does it get destroyed?
Do I need a line of code to destroy the object and release the memory it was using, or does it get destroyed automatically at the end of the subroutine in which it was created?
for example, in the subroutine below, does the object BPFeature still exist and is it still using memory when the subroutine ends? Because if thats the case, if I run this subroutine enough then I would just be wasting system memory...
From what I understand, the way I have written my code below, the system doesnt actually create my class object BPFeature until the line
Code:
Set BPFeature = New ClaBPFeature
So if thats when the object is created, I'm wondering, when does it get destroyed?
Do I need a line of code to destroy the object and release the memory it was using, or does it get destroyed automatically at the end of the subroutine in which it was created?
for example, in the subroutine below, does the object BPFeature still exist and is it still using memory when the subroutine ends? Because if thats the case, if I run this subroutine enough then I would just be wasting system memory...
Code:
Sub testClass()
Dim rngItem As Range
Dim BPFeature As ClaBPFeature
Set rngItem = Intersect(Range("A:A"), Selection.Rows.EntireRow)
Set BPFeature = New ClaBPFeature
With BPFeature
.Item = rngItem.Value
.InputDescription = rngItem.Offset(0, 1).Value
.Nominal = rngItem.Offset(0, 2).Value
.HighTolerance = rngItem.Offset(0, 3).Value
.LowTolerance = rngItem.Offset(0, 4).Value
.Method = rngItem.Offset(0, 5).Value
.Zone = rngItem.Offset(0, 6).Value
End With
If ThisWorkbook.Sheets("INPUT").Range("H2").Value = "Metric" Then
BPFeature.Metric = True
Else
BPFeature.Metric = False
End If
End Sub