Solved

ERROR : object or with block variable not defined

Posted on 2003-10-28
17
175 Views
Last Modified: 2010-05-03
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)

0
Comment
Question by:Hyperon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 4
17 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9632540
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
 

Author Comment

by:Hyperon
ID: 9632649
I tried to use set Grid(0 to 3) = new aGrid

but that didnt work, ill try your idea
0
 

Author Comment

by:Hyperon
ID: 9632658
Sorry, Didnt work
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Hyperon
ID: 9632661
sorry, the error is : object variable or with block variable not set
0
 
LVL 13

Accepted Solution

by:
crazyman earned 25 total points
ID: 9632888
public Grid(0 to 3) as aGrid

'--------
dim i as long
For i = 0 To 3
    Set Grid(i) = new agrid
Next
0
 

Author Comment

by:Hyperon
ID: 9633498
sorry, no results
0
 

Author Comment

by:Hyperon
ID: 9634293
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
 
LVL 13

Expert Comment

by:crazyman
ID: 9634308
can you paste your code?
0
 

Author Comment

by:Hyperon
ID: 9634320
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
 

Author Comment

by:Hyperon
ID: 9634371
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
 
LVL 13

Expert Comment

by:crazyman
ID: 9634674
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
 

Author Comment

by:Hyperon
ID: 9634748
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
 

Author Comment

by:Hyperon
ID: 9636994
Thanxs for all your help I sorted out the problem now and its all fixed and done, thanxs to everyone that helped.
0
 

Author Comment

by:Hyperon
ID: 9644700
do you have to

set acollection = new collection

?????
0
 
LVL 13

Expert Comment

by:crazyman
ID: 9648415
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
 

Author Comment

by:Hyperon
ID: 9648505
thanks
0
 

Author Comment

by:Hyperon
ID: 9648526
does it work the same for public acollection as collection?
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question