Subscript Out Of Range Error Message
Subscript Out Of Range Error Message
(OP)
Hi, i'm in the process of coding a visual basic RPG game. I have recently added code to allow 1 square of the map to be turned into an object which teleports the user to another map. Although upon running the program it crashes at the stage where the program loads the item responsible for teleporting the user. The debug message is that of a 'Subscript Out Of Range' error, as shown here: http:// i71.photob ucket.com/ albums/i14 8/Thunder2 k6/vb1.jpg
Upon debugging the program the error is displayed at the following line in the code: http:// i71.photob ucket.com/ albums/i14 8/Thunder2 k6/vb2.jpg
Now the .Type variable is supposed to display 0 but for some reason it comes up with the Subscript error message, I have no idea why and I have used loads of different breakpoints to try and find the root of the problem, and have also tried removing sections of the code in order to make it work, as well as setting the variable to 0 manually. Can anyone help me to show me where i'm going wrong?
Thanks in advance,
Thunder
Upon debugging the program the error is displayed at the following line in the code: http://
Now the .Type variable is supposed to display 0 but for some reason it comes up with the Subscript error message, I have no idea why and I have used loads of different breakpoints to try and find the root of the problem, and have also tried removing sections of the code in order to make it work, as well as setting the variable to 0 manually. Can anyone help me to show me where i'm going wrong?
Thanks in advance,
Thunder
RE: Subscript Out Of Range Error Message
The variable CurObjNo% does not relate to an item in the Item array, or is Item a collection? Has Item been initialized correctly?
If Item is a collection then:Collections are 1 based, and CurObj% may equal zero. That is usaually what happens to me in these cases.
RE: Subscript Out Of Range Error Message
The CurObjNo% variable is used to define which Item is being drawn or is shown in the Inventory.
The (CurObjNo%) part is fine, thats displaying the correct value and that is shown when the mouse is hovered over it, but the .Type part of the variable is supposed to display 0, which it doesn't. This problem is driving me nuts because I can't find the cause of it lol.
Also, what does the Subscript Out Of Range error message mean? I've only been using VB for about a year and haven't encountered it before.
Thanks,
Thunder
RE: Subscript Out Of Range Error Message
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
Steam Engine enthusiasts: www.essexsteam.co.uk
RE: Subscript Out Of Range Error Message
Cheers,
Joerd
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: Subscript Out Of Range Error Message
Anyway, thanks for all the help.
Thunder