LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default how to test if an object is dimensioned

How do you tell if an object array element is set? For example, I have a
class I've made which is dimensioned as an array in my program:
dim roll() as cRoll

I've tried using statements like
If roll(i) is nothing then ...
but that gives a subscript out of range error if I haven't already done
something like
set roll(i) = new cRoll

I've also attempted using things like
if roll is null then ...
if roll is empty then ...
but nothing works for me.

When I have this problem with finding whether a worksheet exists I use
something like the following, which, by the way, I find rather cumbersome.
It would make more sense to me to have something simple like:
if not worksheet("sheetName") is nothing then....
but instead I need to use the 8 or so lines of code shown below

Can someone straighten me out?

dim wk as worksheet, alreadyThere as boolean
for each wk is worksheets
if wk.name="sheetName" then
alreadyThere = true
exit for
end if
next
If not already there then
worksheets.add ... etc....

 
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
Can you help test our Excel test? Jeff[_14_] Excel Discussion (Misc queries) 1 December 7th 09 05:11 PM
how to test if range object target deleted Bob Flanagan[_2_] Excel Programming 1 January 25th 08 10:36 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
How to test if an object exist really Jean-Pierre Bidon Excel Programming 3 April 18th 06 02:24 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM


All times are GMT +1. The time now is 10:21 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"