?
Solved

Question about "Nothing"

Posted on 1998-08-21
10
Medium Priority
?
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430244
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
ID: 1430245
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
ID: 1430246
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:bernfarr
ID: 1430247
What about the Is operator?

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

0
 
LVL 2

Author Comment

by:Jagar
ID: 1430248
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
 
LVL 6

Expert Comment

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

Expert Comment

by:clifABB
ID: 1430250
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 120 total points
ID: 1430251
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
ID: 1430252
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
ID: 1430253
That and the things you just don't think about.  I hate writing code that relies on an error.  Thanks bernfarr!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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