Question about "Nothing"

Like the title actually I'm referring to the keyword Nothing

I have a loop the goes through a bunch of object when it has finished with all the object the object will be set to Nothing what I need is a loop that checks this object at the end of the loop and continues to process until it becomes nothing, ie.

do
  proccesing
loop while not IsNothing(MyVariable)

IsNothing is not a real function unfortunately and I can do something not MyVariable = Nothing.  So how do I do something like the about
LVL 2
JagarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

a111a111a111Commented:
here is a code for your Q

Private Sub Command1_Click()

Dim Found, MyObject, MyCollection
Found = False   ' Initialize variable.
For Each MyObject In MyCollection   ' Iterate through each element.
    Set MyObject = Nothing
Next

End Sub


0
clifABBCommented:
So, create a function 'IsNothing':
Public Function IsNothing(objTarget As Object) As Boolean
  Dim sText As String
 
  On Error Resume Next
  sText = objTarget.Name
  If Err.Number = 91 Then
    IsNothing = False
  Else
    IsNothing = True
  End If
End Function

0
JagarAuthor Commented:
No in the process I control the flow through the object.  It is not necessarily from beginning to end.  It can move forward and back sides.  Skip this or that depending on user interaction with the flow.
So I can just iterate through each element.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

bernfarrCommented:
What about the Is operator?

do
   ...
   Set MyVariable = Nothing
   ...
loop while not (MyVariable Is Nothing)

0
JagarAuthor Commented:
Thanks Cliff that's kinda the work around that I have been using.  But did it in the processing because it would give an error when it tried to do the processing on the nothing object.

I was hoping that there would be some function or something that I overlooked.
Well I guess not, so resubmit as an answer and I'll give you the points.
0
clifABBCommented:
bernfarr:
Why didn't you submit that as an answer!
0
clifABBCommented:
Before I submit, check out bernfarr's answer.  If you were to code:
do
  proccesing
loop while not (MyVariable Is Nothing)
it should work as you want.

0
bernfarrCommented:
I tried, but was beaten by the previous one.

What about the Is operator?

do
   ...
   Set MyVariable = Nothing
   ...
loop while not (MyVariable Is Nothing)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagarAuthor Commented:
Thanks that's what I was looking for.  It's amazing some of the things you forget about.
Thanks Cliff for your help.
0
clifABBCommented:
That and the things you just don't think about.  I hate writing code that relies on an error.  Thanks bernfarr!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.