Hi all,
How to verify that an object is valid and has not been deleted.
Using this code to get and ObjPtr object.
https://www.vbforums.com/showthread....=1#post5161749
If by some mistake I delete the object.
How to verify that the variable is not a valid object, the program does not close when using it.
Thanks
How to verify that an object is valid and has not been deleted.
Using this code to get and ObjPtr object.
https://www.vbforums.com/showthread....=1#post5161749
Code:
Private Declare Function vbaObjSetAddref Lib "MSVBVM60.DLL" _
Alias "__vbaObjSetAddref" ( _
ByRef dstObject As Any, _
ByRef srcObjPtr As Any) As Long
Private Sub Form_Load()
Dim frm As Form1
Set frm = COMObjectFromPtr(ObjPtr(Me))
frm.Circle (100, 100), 100
End Sub
' //
' // Get COM object from pointer
' //
Public Function COMObjectFromPtr( _
ByVal ptr As Long) As IUnknown
vbaObjSetAddref COMObjectFromPtr, ByVal ptr
End Function
How to verify that the variable is not a valid object, the program does not close when using it.
Thanks