VBA 2013 IsNothing equivalent

I am currently debugging a DB application originally written in VBA 2005 that does not work with versions of VBA 2010 and above. One of the (many) problems is that it uses the IsNothing function to check if the object variable has an object attached to it. This feature seems to be deprecated in 2010 and 2013. Is there an equivalent to this feature in VBA 2013?

+4
source share
4 answers

As others IsNothinghave pointed out, it was never a VBA function and was probably written as syntactic sugar for Is Nothing.

VB IsNothing, . , VBA, VB, .

VBA IsNothing Tek-Tips, , - IsNothing as-is... :

'**********************************************************
'* Function: Returns true if argument evaluates to nothing
'* 1. IsNothing(Nothing) -> True
'* 2. IsNothing(NonObjectVariableOrLiteral) -> False
'* 3. IsNothing(ObjectVariable) -> True if instantiated, 
'*                                 otherwise False
'**********************************************************
Public Function IsNothing(pvarToTest As Variant) As Boolean
    On Error Resume Next
    IsNothing = (pvarToTest Is Nothing)
    Err.Clear
    On Error GoTo 0
End Function 'IsNothing

, , , , @HansUp, , , , , , .

+3

VBA IsNothing. , .

, .

Public Function IsNothing(ByRef pObject As Variant) As Boolean
    IsNothing = (pObject Is Nothing)
End Function
+2

Dim x as Object

If x is Nothing then
0

IsNothing itself has never been a VBA function ...

If obj Is Nothing Then...

may work for you, but may not produce the same results as the IsNothing function you expect. You may need to program more specific checks, depending on what you want to determine.

0
source

Source: https://habr.com/ru/post/1531468/


All Articles