In VB6 you could do something like this
But this gives me an error in .net, any idea how I can do this. Load a binary file directly to a class? I'll find the error if you guys need.Code:Public Class MapRec Public Name As String Public Moral As Byte Public Up As Long Public Down As Long Public Left As Long Public right As Long Public Music As String Public BootMap As Long Public BootX As Byte Public BootY As Byte Public Shop As Long Public Indoors As Byte Public Tile(0 To Max_mapwidth, 0 To Max_mapheight) As TileRec Public Npc(0 To MAX_MAP_NPCS) As Long Public Owner As String Public Weather As Long Public lights As Long Public Sub New() Name = "" Moral = 0 Up = -1 Down = -1 Left = -1 right = -1 Music = -1 BootMap = -1 BootX = 0 BootY = 0 Shop = -1 Indoors = 0 Owner = "" Weather = -1 lights = -1 End Sub End Class Module MapData Public Map(0 To MAX_MAPS) As MapRec Sub SaveLocalMap(ByVal MapNum As Long) Dim FileName As String Dim f As Long FileName = Application.StartupPath & "\maps\map" & MapNum & ".dat" f = FreeFile() FileOpen(f, FileName, OpenMode.Binary) FilePutObject(f, Map(MapNum)) FileClose(f) End Sub Sub LoadMap(ByVal MapNum As Long) Dim FileName As String Dim f As Long FileName = Application.StartupPath & "\maps\map" & MapNum & ".dat" If FileExist("maps\map" & MapNum & ".dat") = False Then Exit Sub f = FreeFile() FileOpen(f, FileName, OpenMode.Binary) FileGetObject(f, Map(MapNum)) FileClose(f) End Sub End Module




Reply With Quote