Solved

Question about "Nothing"

Posted on 1998-08-21
10
182 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:Jagar
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:a111a111a111
Comment Utility
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
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 
LVL 2

Author Comment

by:Jagar
Comment Utility
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
 
LVL 2

Expert Comment

by:bernfarr
Comment Utility
What about the Is operator?

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

0
 
LVL 2

Author Comment

by:Jagar
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 6

Expert Comment

by:clifABB
Comment Utility
bernfarr:
Why didn't you submit that as an answer!
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
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
 
LVL 2

Accepted Solution

by:
bernfarr earned 30 total points
Comment Utility
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
 
LVL 2

Author Comment

by:Jagar
Comment Utility
Thanks that's what I was looking for.  It's amazing some of the things you forget about.
Thanks Cliff for your help.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
That and the things you just don't think about.  I hate writing code that relies on an error.  Thanks bernfarr!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now