I gave the saving a try and seems to be working. Bit intermittent but before i say anything ill have a proper look into so i dont end up wittering a lot of rubbish.
frm2 is declared at the very top of the class. it works when i try to open it the first time, but then if i go back, add another name and score (I shut down frm2) then click on the button to open up frm 2 again thats when i get the error.
I'm still testing it as it seems a bit sporadic for me at the moment.
If i find anything certain i'll let you know.
Thanks
Craig
33 Replies - 724 Views - Last Post: 18 January 2013 - 10:28 AM
#32
Re: Using XML for High Score Table
Posted 18 January 2013 - 09:28 AM
If you shutdown the 2nd form then you cannot issue frm2.Show() again as it no longer exists - it has been disposed of. You would need to create a new instance of it; or not shut it down, just Hide() it.
I'm assuming of course that your forms and controls are not named ListBox1, Button1, etc., etc.
I'm assuming of course that your forms and controls are not named ListBox1, Button1, etc., etc.
#33
Re: Using XML for High Score Table
Posted 18 January 2013 - 10:11 AM
Ah cheers, using the hide() solved it.
I was noticing that once a score and name was added, the listbox displayed e.g. 10 craig
but then if i added another name and score it would then show
10 craig
11james
10craig
So the first record would remain.
I solved this with Listbox.items.clear(), So when i hit the return key on frm2 it clears the listbox.
All i have done is created another problem as if you dont add another record the listbox remains empty because it is printing to the listbox when i add a score.
So im guessing this comes back to the old problem of getting it so when it loads up frm2 it prints to the listbox?
I was noticing that once a score and name was added, the listbox displayed e.g. 10 craig
but then if i added another name and score it would then show
10 craig
11james
10craig
So the first record would remain.
I solved this with Listbox.items.clear(), So when i hit the return key on frm2 it clears the listbox.
All i have done is created another problem as if you dont add another record the listbox remains empty because it is printing to the listbox when i add a score.
So im guessing this comes back to the old problem of getting it so when it loads up frm2 it prints to the listbox?
#34
Re: Using XML for High Score Table
Posted 18 January 2013 - 10:28 AM
Managed to sort it out! 
Put this code
Into the button click and it works. No duplicate names and scores and sorts them out perfectly.
If i can get them to save its a winner and done!
Thanks again for all your help
Craig
Put this code
Dim theScores As New List(Of Scores)
'MsgBox(score.ToString())
For Each score As String In My.Settings.HighScores
Dim values() As String = score.Split(";")
theScores.Add(New Scores With {.Score = Int32.Parse(values(0)), .Name = values(1)})
Next
'add these to a form control
For Each score As Scores In theScores.OrderByDescending(Function(aScore) aScore.Score)
MsgBox(score.Score & score.Name)
frm3.ListBox1.Items.Add(score.Score & " " & score.Name)
Next
Into the button click and it works. No duplicate names and scores and sorts them out perfectly.
If i can get them to save its a winner and done!
Thanks again for all your help
Craig
|
|

New Topic/Question
Reply




MultiQuote



|