Solved

Problem using GetObject("WinNT:")

Posted on 2004-08-27
2
1,845 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
Comment Utility
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
Comment Utility
Thanks for the response. I'll give this a try this afternoon.

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

743 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

14 Experts available now in Live!

Get 1:1 Help Now