I have defined a variable with an own type, say
Dim point As DataPoint Public Type DataPoint list as Collection name as String number as Integer End Type
and I want to delete all values of the variable point
at once. If it was a class, I would just use Set point = New DataPoint
, or set Set point = Nothing
, but how can I proceed if it's a type?
Assigning Nothing To free an object variable so that it no longer points to anything, assign the "Nothing" keyword. (eg Set rgeRange = Nothing). It is good programming practice to free object variables when they are no longer needed, since this can save resources.
There is no isNothing() function in VBA (see is… () functions).
“Set”, is a keyword used in VBA programming to assign a reference to an object or cell range which is going to remain fix throughout the program or code in Excel. VBA Set basically helps us in avoiding repetitive input of range we need to select while executing the code.
You can benefit from the fact that functions in VB have an implicit variable that holds the result, and that contains the default type value by default.
public function GetBlankPoint() as DataPoint end function
Usage:
point = GetBlankPoint()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With