Skip to main content

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password
Register
  • Home
  • Browse
    • 2D Art
    • 3D Art
    • Concept Art
    • Textures
    • Music
    • Sound Effects
    • Documents
    • Featured Tutorials
  • Submit Art
  • Collect
    • My Collections
    • Art Collections
  • Forums
  • FAQ
  • Leaderboards
    • All Time
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
    • Weekly
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
  • ❤ Donate
Programming

VB Save Help

old_school
Saturday, October 15, 2011 - 16:44

Im having a issue with saving data on my game. Ive never had to make a save option before so I need a little help. Its basicly not saving correctly right now or loading data properly and Im not sure what the issue is with it currently.

 

Using Visual Studio 2010

written in VB:

 

Private

 

Sub btn_Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

btn_Save.Click

'Actions Taken

ProcessTimer.Start()

storage.Saving =

True

frmLoadSave =

NewLoad_Save

(storage)

'Save Action

Dim AntFarmObject AsStorage = NewStorage

()

' Insert code to set properties and fields of the object.

Dim AntFarmSerializer As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Storage

))

' To write to a file, create a StreamWriter object.

Dim AntFarmWriter AsStreamWriter = NewStreamWriter("Ant.Loc"

)

AntFarmSerializer.Serialize(AntFarmWriter, AntFarmObject)

AntFarmWriter.Close()

End

Sub

PrivateSub btn_Load_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

btn_Load.Click

'Actions Taken

ProcessTimer.Start()

storage.Loading =

True

frmLoadSave =

NewLoad_Save

(storage)

'Load Action

Dim AntFarmObject As

Storage

' Construct an instance of the XmlSerializer with the type

' of object that is being deserialized.

Dim AntFarmSerializer As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Storage

))

' To read the file, create a FileStream.

Dim AntFarmFileStream AsFileStream

= _

NewFileStream("Ant.Loc", FileMode

.Open)

' Call the Deserialize method and cast to the object type.

AntFarmObject =

CType

( _

AntFarmSerializer.Deserialize(AntFarmFileStream),

Storage

)

End

Sub

  • Log in or register to post comments