VB Save Help
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