Testing nothing objects 
Author Message
 Testing nothing objects

I have to admit that I'm a beginner in VB.

I need to use the HitTest method for a TreeView control. It sais that
HitTest returns the node coresponding to the x, y coordinates I'm
giving as parameter, and if no node is found to that location, HitTest
returns Nothing.
I write somthing like
          Set xNode = HitTest(...)
          If Isnumeric(xNode) then
             ... do something ...
          Else
             ... do something else
          Endif
but I got an error in the If block when HitTest returns nothing.

So, how can I test first that xNode is Nothign?



Thu, 24 Nov 2005 00:11:23 GMT  
 Testing nothing objects
Hello,


Quote:
> I write somthing like
>           Set xNode = HitTest(...)
>           If Isnumeric(xNode) then
>              ... do something ...
>           Else
>              ... do something else
>           Endif
> but I got an error in the If block when HitTest returns nothing.

> So, how can I test first that xNode is Nothign?

\\\
If xNode Is Nothing Then
    ...
Else
    ...
End If
///

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Thu, 24 Nov 2005 00:16:42 GMT  
 Testing nothing objects
Set xNode = HitTest(...)

If xNode Is Nothing Then Return

If IsNumeric(xNode) Then
    ...
Else
    ...
End If

HTH,
Jeremy


Quote:
> I have to admit that I'm a beginner in VB.

> I need to use the HitTest method for a TreeView control. It sais that
> HitTest returns the node coresponding to the x, y coordinates I'm
> giving as parameter, and if no node is found to that location, HitTest
> returns Nothing.
> I write somthing like
>           Set xNode = HitTest(...)
>           If Isnumeric(xNode) then
>              ... do something ...
>           Else
>              ... do something else
>           Endif
> but I got an error in the If block when HitTest returns nothing.

> So, how can I test first that xNode is Nothign?



Thu, 24 Nov 2005 00:19:35 GMT  
 Testing nothing objects

Rares,

            Try enclosing it in a try, Catch, end try block.

            Try

Quote:
>           Set xNode = HitTest(...)
>           If Isnumeric(xNode) then
>              ... do something ...
>           Else
>              ... do something else
>           Endif

            Catch
                ' do nothing
            End try

Ken
-----------------

Quote:

> I have to admit that I'm a beginner in VB.

> I need to use the HitTest method for a TreeView control. It sais that
> HitTest returns the node coresponding to the x, y coordinates I'm
> giving as parameter, and if no node is found to that location, HitTest
> returns Nothing.
> I write somthing like
>           Set xNode = HitTest(...)
>           If Isnumeric(xNode) then
>              ... do something ...
>           Else
>              ... do something else
>           Endif
> but I got an error in the If block when HitTest returns nothing.

> So, how can I test first that xNode is Nothign?



Thu, 24 Nov 2005 00:25:36 GMT  
 Testing nothing objects

It is preferred to test for the Nothing value first, rather than just
letting the error fire every time.



  Rares,

              Try enclosing it in a try, Catch, end try block.

              Try
  >           Set xNode = HitTest(...)
  >           If Isnumeric(xNode) then
  >              ... do something ...
  >           Else
  >              ... do something else
  >           Endif
              Catch
                  ' do nothing
              End try

  Ken
  -----------------



  > I have to admit that I'm a beginner in VB.
  >
  > I need to use the HitTest method for a TreeView control. It sais that
  > HitTest returns the node coresponding to the x, y coordinates I'm
  > giving as parameter, and if no node is found to that location, HitTest
  > returns Nothing.
  > I write somthing like
  >           Set xNode = HitTest(...)
  >           If Isnumeric(xNode) then
  >              ... do something ...
  >           Else
  >              ... do something else
  >           Endif
  > but I got an error in the If block when HitTest returns nothing.
  >
  > So, how can I test first that xNode is Nothign?



Thu, 24 Nov 2005 00:32:01 GMT  
 Testing nothing objects

Thanks a lot, Herfried

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  _alt.0
3K Download


Thu, 24 Nov 2005 00:39:36 GMT  
 Testing nothing objects
Hello,


Quote:
>It is preferred to test for the Nothing value first,
> rather than just letting the error fire every time.

You should test for nothing first whenever possible.

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Thu, 24 Nov 2005 01:18:53 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to test if an object equals nothing

2. Testing for object set to Nothing - Please help!

3. How to test if an object equals nothing

4. Testing an Object equal to Nothing

5. Testing whether object = nothing

6. Test see if object = nothing

7. Test object for "Nothing"

8. Object = Nothing type test...

9. How to test is an object = NOTHING

10. How to test if object is Nothing?

11. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

12. How can I get whether Object variable is nothing (=nothing) or not

 

 
Powered by phpBB® Forum Software