Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to test if an object exist really

Hie,
I try (unsuccesfully to test if an object of my own is "Nothing" or not
I created an object class, let's call it MyClass.
Thren I declared an instance of this variable like this:

Dim MyObj as new MyClass
Dim boTest as boolean

Set MyObj = Nothing
boTest = MyObj Is Nothing

Strangely, boTest is false! (I hoped this test retrun was true)
The question is : where did I make a mistake.
Thanks for your help.

--
Jean-Pierre Bidon
Interstat
91 rue de Rennes
75006 Paris
Tél: 01 45 49 19 17


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to test if an object exist really

Try:

Dim MyObj As myClass
Dim boTest As Boolean

Set MyObj = New myClass
Set MyObj = Nothing
boTest = MyObj Is Nothing

And then read Chip Pearson's explanation:
http://www.cpearson.com/excel/variables.htm

Look for:
Don't Use The New Keyword In A Dim Statement

Jean-Pierre Bidon wrote:

Hie,
I try (unsuccesfully to test if an object of my own is "Nothing" or not
I created an object class, let's call it MyClass.
Thren I declared an instance of this variable like this:

Dim MyObj as new MyClass
Dim boTest as boolean

Set MyObj = Nothing
boTest = MyObj Is Nothing

Strangely, boTest is false! (I hoped this test retrun was true)
The question is : where did I make a mistake.
Thanks for your help.

--
Jean-Pierre Bidon
Interstat
91 rue de Rennes
75006 Paris
Tél: 01 45 49 19 17


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default How to test if an object exist really

Instead of

Dim MyObj as new MyClass

use

Dim MyObj as MyClass

"Jean-Pierre Bidon" wrote:

Hie,
I try (unsuccesfully to test if an object of my own is "Nothing" or not
I created an object class, let's call it MyClass.
Thren I declared an instance of this variable like this:

Dim MyObj as new MyClass
Dim boTest as boolean

Set MyObj = Nothing
boTest = MyObj Is Nothing

Strangely, boTest is false! (I hoped this test retrun was true)
The question is : where did I make a mistake.
Thanks for your help.

--
Jean-Pierre Bidon
Interstat
91 rue de Rennes
75006 Paris
Tél: 01 45 49 19 17



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to test if an object exist really

Thank you very much ... for the solution and the explanation!

"Dave Peterson" a écrit dans le message de news:
...
Try:

Dim MyObj As myClass
Dim boTest As Boolean

Set MyObj = New myClass
Set MyObj = Nothing
boTest = MyObj Is Nothing

And then read Chip Pearson's explanation:
http://www.cpearson.com/excel/variables.htm

Look for:
Don't Use The New Keyword In A Dim Statement

Jean-Pierre Bidon wrote:

Hie,
I try (unsuccesfully to test if an object of my own is "Nothing" or not
I created an object class, let's call it MyClass.
Thren I declared an instance of this variable like this:

Dim MyObj as new MyClass
Dim boTest as boolean

Set MyObj = Nothing
boTest = MyObj Is Nothing

Strangely, boTest is false! (I hoped this test retrun was true)
The question is : where did I make a mistake.
Thanks for your help.

--
Jean-Pierre Bidon
Interstat
91 rue de Rennes
75006 Paris
Tél: 01 45 49 19 17


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object does not exist. Jerry McNabb Excel Discussion (Misc queries) 4 February 8th 08 08:01 PM
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. Tintin92 Excel Programming 3 March 11th 06 06:45 PM
Test if Cell is Empty or Doesn't Exist scott Excel Programming 2 February 7th 05 10:49 PM
test if a sheet exist (with the name) ? LoloSoft Excel Programming 4 February 17th 04 02:39 PM


All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"