ScratchData LogoScratchData
Back to mrtrain's profile

Phil Swift Flex Tape Simulator

MRmrtrain•Created January 6, 2019
Phil Swift Flex Tape Simulator
139
105
3678 views
View on Scratch

Instructions

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim doc As XDocument = XDocument.Load("Score.xml") Dim table As New DataTable() ' Get a list of all the <entry> elements in the XML file Dim entries As List(Of XElement) = doc.Root.Elements("entry").ToList() For Each entry As XElement In entries Dim name As String = entry.Element("Names").Value Dim score As String = entry.Element("Score").Value lstHiScores.Items.Add(score + "," + name) Next

Description

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim doc As XDocument = XDocument.Load("Score.xml") Dim table As New DataTable() ' Get a list of all the <entry> elements in the XML file Dim entries As List(Of XElement) = doc.Root.Elements("entry").ToList() For Each entry As XElement In entries Dim name As String = entry.Element("Names").Value Dim score As String = entry.Element("Score").Value lstHiScores.Items.Add(score + "," + name) Next End Sub Private Sub vsbScore_Scroll(sender As Object, e As ScrollEventArgs) Handles vsbScore.Scroll Select Case vsbScore.Value * -1 Case Is < 10 : Score = "000" + CStr(vsbScore.Value * -1) Case 10 To 99 : Score = "00" + CStr(vsbScore.Value * -1) Case 100 To 999 : Score = "0" + CStr(vsbScore.Value * -1) Case Else : Score = vsbScore.Value * -1 End Select lblScore.Text = Score End Sub Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click lstHiScores.Items.Remove(lstHiScores.Text) End Sub Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click Entry = lblScore.Text + "," + txtName.Text If Isit Then lstHiScores.Items.Insert(lstHiScores.SelectedIndex - 1, Entry) lstHiScores.Items.RemoveAt(lstHiScores.SelectedIndex) Isit = False Else lstHiScores.Items.Add(Entry) End If End Sub Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click Dim HiScFile2 As StreamWriter = File.CreateText("Score.xml") Dim Splt As String HiScFile2.WriteLine("<?xml version=""1.0"" encoding=""UTF-8""?>") HiScFile2.WriteLine("<HiScores>") For Each Name As Object In lstHiScores.Items Splt = Name HiScFile2.WriteLine(" <entry>") Scoresplit = Split(Splt, ",") HiScFile2.WriteLine(" <Score>" + Scoresplit(0) + "</Score>") HiScFile2.WriteLine(" <Names>" + Scoresplit(1) + "</Names>") HiScFile2.WriteLine(" </entry>") Next HiScFile2.WriteLine("</HiScores>") HiScFile2.Close()

Project Details

Project ID277422971
CreatedJanuary 6, 2019
Last ModifiedMarch 17, 2023
SharedJanuary 6, 2019
Visibilityvisible
CommentsAllowed