Solved

Problem using GetObject("WinNT:")

Posted on 2004-08-27
2
1,864 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
[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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

695 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