Solved

Problem using GetObject("WinNT:")

Posted on 2004-08-27
2
1,849 Views
Last Modified: 2006-11-17
I'm currently using the following code to get a listing of all the domains in my LAN. It works fine, but every once in a while, GetObject returns nothing, and I have to recursively call the same routine untill it returns data. I'm confused as to why this is happenning. Can someone help?

Here is the code:

 Dim objNS As IADsContainer
 Dim objDomain As IADs
   
   Set objNS = GetObject("WinNT:")
 
   For Each objDomain In objNS
      cmbDomain.AddItem objDomain.Name
   Next
   
   MsgBox cmbDomain.ListCount
   
   If cmbDomain.ListCount = 0 Then
      Call Form_Load
   End If


* This is an extension of the following question :
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21004965.html
0
Comment
Question by:LeeHenry
2 Comments
 
LVL 1

Accepted Solution

by:
mkrell earned 500 total points
ID: 11927010
maybe this is because of a timeout while getting the object...

use:

Do
   Set objNS = GetObject("WinNT:")
Loop until  not (objNS Is Nothing)

instead of your recursive way.
0
 
LVL 6

Author Comment

by:LeeHenry
ID: 11931107
Thanks for the response. I'll give this a try this afternoon.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now