Solved

Testing return results in MSXML4.0

Posted on 2002-06-26
3
157 Views
Last Modified: 2010-05-02
I'm using MSXML4.0 and have a question about testing the return value of some functions.  I'm using XPath as my selection langauges so I frequently attempt to retrieve nodes using:

    Dim Node As IXMLDOMNode

    node = XMLDoc.selectSingleNode("/foo/bar")

What I would like to do is test the value of the node to ensure it is valid before calling methods on it.  The documentation for selectSingleNode says the return value is Nothing if no node is found to match the XPath expression.  I tried the following:

    If Node = Nothing Then

but I got the following error:

    Compiler Error
    Invalid Use of Object

How can I test the validity of my object in this case?
0
Comment
Question by:derekl
3 Comments
 
LVL 10

Expert Comment

by:GoodJun
ID: 7111699
may be try
If Node then
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 100 total points
ID: 7111708
Dim Node As IXMLDOMNode

set node = XMLDoc.selectSingleNode("/foo/bar")

if not node is nothing then
  ' do something
endif
0
 

Author Comment

by:derekl
ID: 7111929
Thanks.

I'm just curious why If Node doesn't work.  When I try that I get a "Object doesn't support method" error.  I'm thinking maybe a node doesn't support a conversion to boolean?
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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