ERROR : object or with block variable not defined

i have a class, agrid

in it i have (among other things): public special as integer

i call a member of an array defined as follows : public Grid(0 to 3)

The line it spits out :

Grid(3).special = val(tempstr)

HyperonAsked:
Who is Participating?
 
crazymanCommented:
public Grid(0 to 3) as aGrid

'--------
dim i as long
For i = 0 To 3
    Set Grid(i) = new agrid
Next
0
 
AlexFMCommented:
You need to initialize array by the following way:

For i = 0 To 3
    Set Grid(i) = new grid
Next

Bow you can work with Grid array members.
0
 
HyperonAuthor Commented:
I tried to use set Grid(0 to 3) = new aGrid

but that didnt work, ill try your idea
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
HyperonAuthor Commented:
Sorry, Didnt work
0
 
HyperonAuthor Commented:
sorry, the error is : object variable or with block variable not set
0
 
HyperonAuthor Commented:
sorry, no results
0
 
HyperonAuthor Commented:
that isn't the actual part the error is coming up in though. It refuses to believe that we have set it as an integer or string.
0
 
crazymanCommented:
can you paste your code?
0
 
HyperonAuthor Commented:
that last thign worked for one part though. However I have the same error in a different place now, oh well ill fiddle around some more trying to fix it.
0
 
HyperonAuthor Commented:
The new Line that doesn't work now is:-

If Len(tmparray(0)) > 0 Then Grid(tempint).N.Sq = tmparray(0)

it should work but I can't see just why it doesn't.
0
 
crazymanCommented:
firstly what does tmparray contain

what is N in the Grid object

and what is Sq in the N object thats in the Grid object?

0
 
HyperonAuthor Commented:
the tmparray contains the info.

N stands for North(for a game)

Sq stands for Square.

sorry, I forgot to explain that lol. (it has nothing to do with a problem with what is in them.)
0
 
HyperonAuthor Commented:
Thanxs for all your help I sorted out the problem now and its all fixed and done, thanxs to everyone that helped.
0
 
HyperonAuthor Commented:
do you have to

set acollection = new collection

?????
0
 
crazymanCommented:
That depends if you declared 'acollection' like this

dim acollection as new collection

or this

dim acollection as collection

The universally accepted best method is the following

dim acollection as collection
set acollection = new collection
0
 
HyperonAuthor Commented:
thanks
0
 
HyperonAuthor Commented:
does it work the same for public acollection as collection?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.