473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Object Array Bug

I have my class which I want to make a two-dimensional array of.

Public Class SpaceTile
Public Shared TileType As Integer
Public Shared Planet As Integer
Public Shared Occupied As Integer
Public Shared PosX As Integer
Public Shared PosY As Integer
End Class

Public STiles(100,100) As SpaceTile

I initialize each with a loop and:
STiles(x, y) = New SpaceTile

STiles(ctrX, ctrY).TileType = Val(MyLineParts(0))
STiles(ctrX, ctrY).Planet = Val(MyLineParts(1))
STiles(ctrX, ctrY).Occupied = Val(MyLineParts(2))
STiles(ctrX, ctrY).PosX = Val(MyLineParts(3))
STiles(ctrX, ctrY).PosY = Val(MyLineParts(4))

Problem is, it makes all array positions the same. Whenever it makes a new
entry, it and all previous ones are made the same. Anybody have any ideas
here? Thanks!
May 6 '06 #1
3 3969
On Sat, 06 May 2006 00:27:16 GMT, "Mike Adams" <ge****@earthlink.net>
wrote:
I have my class which I want to make a two-dimensional array of.

Public Class SpaceTile
Public Shared TileType As Integer
Public Shared Planet As Integer
Public Shared Occupied As Integer
Public Shared PosX As Integer
Public Shared PosY As Integer
End Class Public STiles(100,100) As SpaceTile I initialize each with a loop and:
STiles(x, y) = New SpaceTile
Set STiles(x, y) = New SpaceTile

I don't think this is your real code
STiles(ctrX, ctrY).TileType = Val(MyLineParts(0))
STiles(ctrX, ctrY).Planet = Val(MyLineParts(1))
STiles(ctrX, ctrY).Occupied = Val(MyLineParts(2))
STiles(ctrX, ctrY).PosX = Val(MyLineParts(3))
STiles(ctrX, ctrY).PosY = Val(MyLineParts(4))
Problem is, it makes all array positions the same. Whenever it makes a new
entry, it and all previous ones are made the same. Anybody have any ideas
here? Thanks!


It looks as if you have an Array of 'Object References' all pointing
to the same Instance
May 6 '06 #2

"J French" <er*****@nowhere.uk> wrote in message
news:44****************@news.btopenworld.com...
On Sat, 06 May 2006 00:27:16 GMT, "Mike Adams" <ge****@earthlink.net>
wrote:
I have my class which I want to make a two-dimensional array of.

Public Class SpaceTile
Public Shared TileType As Integer
Public Shared Planet As Integer
Public Shared Occupied As Integer
Public Shared PosX As Integer
Public Shared PosY As Integer
End Class

Public STiles(100,100) As SpaceTile

I initialize each with a loop and:
STiles(x, y) = New SpaceTile


Set STiles(x, y) = New SpaceTile

I don't think this is your real code


I think the Shared keyword, and the inline class definition, indicate a VB.Net
app, where Set is not needed.
May 6 '06 #3
On Sat, 6 May 2006 10:51:45 -0700, "Steve Gerrard"
<my********@comcast.net> wrote:

"J French" <er*****@nowhere.uk> wrote in message
news:44****************@news.btopenworld.com...
On Sat, 06 May 2006 00:27:16 GMT, "Mike Adams" <ge****@earthlink.net>
wrote:
I have my class which I want to make a two-dimensional array of. Public Class SpaceTile
Public Shared TileType As Integer
Public Shared Planet As Integer
Public Shared Occupied As Integer
Public Shared PosX As Integer
Public Shared PosY As Integer
End Class Public STiles(100,100) As SpaceTile I initialize each with a loop and:
STiles(x, y) = New SpaceTile
Set STiles(x, y) = New SpaceTile I don't think this is your real code

I think the Shared keyword, and the inline class definition, indicate a VB.Net
app, where Set is not needed.


Ah, thanks - I did not spot that

May 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
54
by: tshad | last post by:
I have a function: function SalaryDisplay(me) { var salaryMinLabel = document.getElementById("SalaryMin"); salaryMinLabel.value = 200; alert("after setting salaryMinLabel = " +...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
6
by: Luke | last post by:
Here is my emails to Danny Goodman (but probably he is very busy so he didn't answered it). First email(simple): Subject: JavaScript Arrays " We all know the array can act like HashMap, but is...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
3
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL,...
4
by: Fabrizio | last post by:
Hi I cannot figure why it isn't possible to cast a struct array to an object array. I written a structure like this: public struct Test { private int TestA; private int TestB;
6
by: Jake Barnes | last post by:
I was just reading this article on Ajaxian: http://ajaxian.com/archives/show-love-to-the-object-literal This is a newbie question, but what is the object literal? I thought it was like an...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.