i'm doing a game function which able to save and load game function, i want to do it in a simple way cause only a few information need to collect. :cry:
Here is the save method i use which able to write things into the .txt file which work correctly that the txt have the information wat it written.
-----Save (write to text file)
If respond = MsgBoxResult.Yes Then
strmw.Write(vbCrLf)
'loop all the player status
strmw.WriteLine(String.Format((NumPlayer.Text)))
For x = 1 To Val(NumPlayer.Text)
' write detail in the record
strmw.WriteLine(String.Format((x)))
strmw.WriteLine(String.Format(wpname(x).Text))
strmw.WriteLine(String.Format(wPP(x).Text))
strmw.WriteLine(String.Format(wcounter(x).Text))
savegamesound()
Next
strmw.WriteLine(String.Format(PTurn.Text))
strmw.Close()
MsgBox("Game Saved", MsgBoxStyle.OKOnly)
Else : Exit Sub
End If
--------------- LOad function (read from .txt... i think problem were be here anyone know wat happen?? sory to said that i cant use the "for loop" cause i cant use too much array where my system cannot handle with it so used in the old method. i found out that is only read the first line of my entire text file.. and the other value was empty.. like didnt access to it...
If respond = MsgBoxResult.Yes Then
strmw = File.OpenText(filePath)
'loop the player status according to the "num" value
num = strmw.ReadLine()
If num = "1" Then
game.Pname1.Text = strmw.ReadLine()
game.PP1.Text = strmw.ReadLine()
game.counter1.Text = strmw.ReadLine()
game.PTurn.Text = strmw.ReadLine() 'get whos turn
ElseIf num = "2" Then
game.Pname1.Text = strmw.ReadLine()
game.PP1.Text = strmw.ReadLine()
game.counter1.Text = strmw.ReadLine()
game.Pname2.Text = strmw.ReadLine()
game.PP2.Text = strmw.ReadLine()
game.counter2.Text = strmw.ReadLine()
game.PTurn.Text = strmw.ReadLine() 'get whos turn
ElseIf num = "3" Then
......
ElseIf num = "4" Then
......
End If
strmw.Close()
MsgBox("Loading sucess", MsgBoxStyle.OKOnly)
game.Show()
Me.Hide()
Else : Exit Sub
End If