As an answer to the "un-escapable loop" problem I had a few days back, Object Oriented concepts are directly relevant. The virtual space an object take can be a complex topic and I will try to explain as I can.
Objects are just representation of a concept, or a class in VB. When creating a new object, you use the keyword "New" to tell the compiler that this object is totally another thing. When you have a clsChair class, you ideally want to pump out a chair that is going to be distinguished by other with its properties, its name, tag or any other. When VB sees the "New" keyword, its meaning to create another area in memory where this chair will be stored at. If you have two "New"' 's you will have two areas in your memory allocated to chairs.
Similarly, you can omit the "New" keyword entirely. And it will not give you an error. Because if you do not specify the "New", you will just use the class as default and only object. And note here, ONLY object. Meaning he will re-use the default one over and over.
I say defaut but its not exactly that way, an object is pointed to by its reference address. Say our class resides inside the memory at 0x11AA00, thats the "reference" I will be using. Lets say I want to get the number of legs our chair has, I tell my computer to look at whatever class is stored at 0x11AA0 and return me whatever leg property is in there. It will NOT use the name of the class you defined. And this is exactly the problem.
When using the technique I used, that is, not using a new. You end up with every object ( in this case, pictureboxes) using the same address. Same address means properties having the same values. When looping through my image matrix, the lowerbound and upperbound had the same reference address, therefore the first object is ALSO the last one. Which explains why it stopped after a single iteration. Because it already complete ALL its run in a SINGLE shot ( because every other tile were already affected instantly ).
Take a look at this picture:

No comments:
Post a Comment