Could somebody plz tell me what i'm doing wrong

KiS
03-10-2002, 12:44 PM
HI!

I have a sub that I want to load a map into my game.....
This one:


Sub LoadMap()

Dim NewMapX As String
Dim NewMapY As String

Open "tile.txt" For Input As #1
Line Input #1, NewMapX
Line Input #1, NewMapY


ReDim Map(0 To NewMapX, 0 To NewMapY)

For i = 0 To UBound(Map, 2)
For j = 0 To UBound(Map, 1)
Map(j, i) = 1
Next j
Next i
Close #1

End Sub


And I have a call to it from Form_Load, But when I use this sub my screen gets black and I have to use ctrl-alt-del to come out of the game..... What have I done wrong?

Pookie
03-10-2002, 09:09 PM
There can be a lot of possibilities why it is doing that.

First of all, you use a string to redim the dimensions, don't know if that is a problem (as it worked okay on my computer) but usually you would use an integer instead. Maybe an older version of VB doesn't support this?

Also, put after the first two line inputs:

debug.print NewmapX;Newmapy
end

and check the immediate window (CTRL+G) to see what numbers they hold, as you might be loading in some massive number which takes up all your computer's memory, causing a memory crash.

I gather you have removed some code from that as you have the close command after the loop, indicating you were loading data into the map() variable, in which case it could cause an error problem with different data formats so maybe putting a debug.print in that loop and put a break at the start and use the step mode (f8) to check it.

You also have the Sub as not private, so if you are working on the same level (form) you could be altering variables in another sub with this sub. Though unlikely, sometimes it can cause infinite loops from other subs calling this sub and the vars a keep being altered by each other...

Also when the screen goes black, can you press CTRL+BREAK (Pause button) to halt the program from running?

Hope any of these solutions can help. :)

WeavMan
03-11-2002, 06:20 PM
where ever the picture is saved at you can bring it out manually by typing

("C:/the drive, and place ,then the name of the file")
I am not really sure if that will work.


--WeavMan--:)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum