Link to home
Start Free TrialLog in
Avatar of Hyperon
Hyperon

asked on

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)

Avatar of AlexFM
AlexFM

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.
Avatar of Hyperon

ASKER

I tried to use set Grid(0 to 3) = new aGrid

but that didnt work, ill try your idea
Avatar of Hyperon

ASKER

Sorry, Didnt work
Avatar of Hyperon

ASKER

sorry, the error is : object variable or with block variable not set
ASKER CERTIFIED SOLUTION
Avatar of crazyman
crazyman
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hyperon

ASKER

sorry, no results
Avatar of Hyperon

ASKER

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.
can you paste your code?
Avatar of Hyperon

ASKER

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.
Avatar of Hyperon

ASKER

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.
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?

Avatar of Hyperon

ASKER

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.)
Avatar of Hyperon

ASKER

Thanxs for all your help I sorted out the problem now and its all fixed and done, thanxs to everyone that helped.
Avatar of Hyperon

ASKER

do you have to

set acollection = new collection

?????
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
Avatar of Hyperon

ASKER

thanks
Avatar of Hyperon

ASKER

does it work the same for public acollection as collection?