VBA, Null value and data object not set?

This issue is getting my nerves. In VBA, I can't just say, if MyObject = Null to determine whether the object is set or not. IsNull is pretty uesless since it will report false when the object is not set. VBA treats Null as a value, not an object that hasn't been initialized.

Does anyone knows how to get around it Or maybe there is proper way to determin whether the object is initialized or not Like a simple code MyObject == Null in C#



Answer this question

VBA, Null value and data object not set?

  • Proram

    Andy Pope wrote:
    Hi,

    Try using Is Nothing for objects.

    If MyObject Is Nothing Then
    MsgBox "MyObject is nothing"
    End If

    LOL, hell yeah, it works. Thank you very much.

    I know it must be something this easy. I have been trying to fix this problem and getting around it for days. Finally, oh, finally.....


  • Manash

    Maybe you need IsObject or IsNull
  • Daniel_Bowen

    Hi,

    Try using Is Nothing for objects.

    If MyObject Is Nothing Then
    MsgBox "MyObject is nothing"
    End If



  • VBA, Null value and data object not set?