I have this simple Address class, that only have:
Public street as String
Public number as Integer
Then, i'm creating a instance inside a module calle "mdl1", and using it on the same module function:
Public objectAddress as Address
Public Function f1() As String
Set objectAddress = New Address
objectAddress = "5th street" 'this works fine
If Not isNothing() Then
f1 = objectAddress.street
Else
f1 = vbNullString
End If
End Function
Public Function isNothing() As Boolean
'When entering here, the objectAddres is ALWAYS Nothing, even though i just assigned a value to the street property...
If objectAddress is Nothing then
isNothing = True
Else
isNothing = False
End If
End Function
I've assigned a value to objectAdrress.street on the f1()
function, but when it enters the ìsNothing()`function, the objectAddress is Nothing again.
And when the control comes back to the f1
function, the object returns to having a value and the street property still have the value i assigned it...
So, shouldn't a module "property" behave like a class one? Or the global/local scope doesn't exist inside a module?
SOLVED:
Even though no one got the point of the question, the problem was that I was creating a local object with the same name of the global one, that's why it was always Nothing
when it entered another function.