阅读行的特定部分

我只需要获得一行的一部分 我可以从文件中读取内容,但是我只能读一行。 现在我只读了名字和分数。 这样出来

  

尼尔斯得分:9786

仅仅因为我想确保人们理解数字的含义。 请帮我。 现在我正在使用Visual Basic

Public Class Form17
    Dim up As Integer = 0
    Dim ms As Integer
    Dim ts As Integer
    Dim speed As Integer = 3
    Dim picturebox(7) As PictureBox
    Dim player As Boolean
    Dim jk As Integer
    Dim snelheid As Integer = 2
    Dim punten As Integer = 0
    Dim punts As String
    Dim check As Integer
    Dim playername As String
    Dim highscores As Integer = 0
    Private Sub Form17_KeyDown(sender As Object,e As KeyEventArgs) Handles Me.KeyDown
        If e.KeyValue = Keys.Escape Then
            Me.Close()
            Form3.Show()
        End If
        If PictureBox4.Top >= 90 Then
            If e.KeyValue = Keys.Space Or Keys.Up Then
                speed = 3
                up = True
                Walk.Enabled = False
                PictureBox4.Image = My.Resources.dino_spring
            End If
        End If
        If PictureBox4.Top <= 76 Then
            If e.KeyValue = Keys.Down Then
                smooth_jump.Enabled = False
                speed = 5
            End If
        End If
    End Sub
    Private Sub Form17_Load(sender As Object,e As EventArgs) Handles MyBase.Load
        Dim sr As New System.IO.StreamReader("test.txt")
        Dim sr2 As New System.IO.StreamReader("test.txt")
        Dim i As Integer = 0
        Dim curline As Integer = 0
        Dim ran As Integer = 0
        Dim rnd As Integer = 1

        'komt een woord uit
        Do Until sr.EndOfStream = True
                sr.ReadLine()
                i += 1
            Loop
            sr.Dispose()
        sr.Close()
        rnd = 1
        ran = rnd * i
        highscore.Text = "Best score: " & sr2.ReadLine()
        punts = sr2.ReadLine()
        i += 1
        namelabel.Text = "Best player" & sr2.ReadLine()
        playername = sr2.ReadLine()
        'woord opslaan
        TextBox1.Size = Me.Size
        PictureBox1.Location = New Point(839,140)
        startplace()
        Label2.Visible = False
        Label3.Visible = False
        Label4.Visible = False
        Label5.Visible = False
        Label6.Visible = False
        Best_Score.Enabled = False
        Spelers.Enabled = False
        cactus_plaatsen.Enabled = False
        Grond_bewegen.Enabled = False
        Punten_en_snelheid.Enabled = False
        Walk.Enabled = False
        smooth_jump.Enabled = False
    End Sub
    Private Sub cactus_plaatsen_Tick(sender As Object,e As EventArgs) Handles cactus_plaatsen.Tick
        gameover()
        movecactus()
    End Sub
    Private Sub Timer1_Tick(sender As Object,e As EventArgs) Handles Grond_bewegen.Tick
        checkcactus()
        PictureBox1.Left -= snelheid
        PictureBox2.Left -= snelheid
        PictureBox3.Left -= snelheid
        If PictureBox3.Left <= -530 Then
            PictureBox3.Left = 845
        End If
        If PictureBox1.Left <= -530 Then
            PictureBox1.Left = 845
        End If
        If PictureBox2.Left <= -315 Then
            PictureBox2.Left = 1060
        End If
    End Sub
    Private Sub Spelers_Tick(sender As Object,e As EventArgs) Handles Spelers.Tick
        If up = False Then
            ts += 1
            PictureBox4.Top += speed
            If ts = 35 Then
                up = Nothing
            End If
        End If
        If up = True Then
            ms += 1
            If ms = 35 Then
                ms = 0
                up = False
            End If
        End If
        If up = True Then
            PictureBox4.Top -= speed

        End If
        If up = Nothing Then

        End If
        If PictureBox4.Top >= 92 Then
            speed = 0
            PictureBox4.Top = 92
            Walk.Enabled = True
        End If
        If speed = 0 Then
            smooth_jump.Enabled = True
        End If
    End Sub
    Private Sub createarray()
        picturebox(0) = PictureBox5
        picturebox(1) = PictureBox6
        picturebox(2) = PictureBox7
        picturebox(3) = PictureBox8
        picturebox(4) = PictureBox9
    End Sub
    Private Sub gameover()

        For i = 0 To 7
            If PictureBox4.Bounds.IntersectsWith(Label2.Bounds) Then
                tried()
                Label2.Left = -10
            End If
            If PictureBox4.Bounds.IntersectsWith(Label3.Bounds) Then
                tried()
                Label3.Left = -10
            End If
            If PictureBox4.Bounds.IntersectsWith(Label4.Bounds) Then
                tried()
                Label4.Left = -10
            End If
            If PictureBox4.Bounds.IntersectsWith(Label5.Bounds) Then
                tried()
                Label5.Left = -10
            End If
            If PictureBox4.Bounds.IntersectsWith(Label6.Bounds) Then
                tried()
                Label6.Left = -10
            End If
        Next
    End Sub
    Private Sub deadmsg()
        Spelers.Enabled = False
        cactus_plaatsen.Enabled = False
        Grond_bewegen.Enabled = False
        Punten_en_snelheid.Enabled = False
        Walk.Enabled = False
        MsgBox("GAME OVER")
        Form3.Show()
        Me.Close()

    End Sub
    Private Sub tekstt()
        Dim name As String = TextBox1.Text
        Dim score As String = Label1.Text
        Using objreader As New System.IO.StreamWriter("test.txt",True)
            objreader.WriteLine(name)
            objreader.WriteLine(score)
        End Using
    End Sub
    Private Sub movecactus()
        PictureBox5.Left -= snelheid
        PictureBox6.Left -= snelheid
        PictureBox7.Left -= snelheid
        PictureBox8.Left -= snelheid
        PictureBox9.Left -= snelheid
        Label2.Left -= snelheid
        Label3.Left -= snelheid
        Label4.Left -= snelheid
        Label5.Left -= snelheid
        Label6.Left -= snelheid
    End Sub
    Private Sub checkcactus()
        For i = 2 To 6
            If snelheid = i Then
                If PictureBox5.Left <= -100 Then
                    PictureBox5.Left= 2100
                    Label2.Left= PictureBox5.Left + 10
                End If
                If PictureBox6.Left <= -100 Then
                    PictureBox6.Left = 2100
                    Label3.Left = PictureBox6.Left + 10
                End If
                If PictureBox7.Left <= -100 Then
                    PictureBox7.Left = 2100
                    Label4.Left = PictureBox7.Left + 10
                End If
                If PictureBox8.Left <= -100 Then
                    PictureBox8.Left = 2100
                    Label5.Left = PictureBox8.Left + 10
                End If
                If PictureBox9.Left <= -100 Then
                    PictureBox9.Left = 2100
                    Label6.Left = PictureBox9.Left + 10
                End If
            End If
        Next
    End Sub
    Private Sub startplace()
        PictureBox5.Location = New Point(1750,112)
        PictureBox6.Location = New Point(350,112)
        PictureBox7.Location = New Point(700,112)
        PictureBox8.Location = New Point(1050,112)
        PictureBox9.Location = New Point(1400,112)
        Label2.Location = New Point(1760,118)
        Label3.Location = New Point(360,118)
        Label4.Location = New Point(710,118)
        Label5.Location = New Point(1060,118)
        Label6.Location = New Point(1410,118)
    End Sub
    Private Sub Walk_Tick(sender As Object,e As EventArgs) Handles Walk.Tick
        jk += 1
        If jk = 5 Then
            PictureBox4.Image = My.Resources.dino_links
        End If
        If jk = 10 Then
            PictureBox4.Image = My.Resources.dino_rechts
            jk = 0
        End If
    End Sub
    Private Sub Punten_en_snelheid_Tick(sender As Object,e As EventArgs) Handles Punten_en_snelheid.Tick
        punten += 1
        If punten = 5 Then
            punten = 0
            punts += 1
            check += 1
            Label1.Text = "Score: " & punts
        End If
        If check = 200 Then
            check = 0
            snelheid += 1
            If snelheid = 5 Then
                snelheid = 4
            End If
        End If
    End Sub

    Private Sub Smooth_jump_Tick(sender As Object,e As EventArgs) Handles smooth_jump.Tick
        If PictureBox4.Top <= 50 Then
            speed = 3
        End If
        If PictureBox4.Top <= 20 Then
            speed = 1
        End If
    End Sub

    Private Sub tried()
        Dim top As String = TextBox1.Text
        If punts > highscores Then

            Using My.Computer.FileSystem.OpenTextFileWriter("test.txt",False)
            End Using
            tekstt()
            deadmsg()
        End If
    End Sub

    Private Sub TextBox1_KeyPress(sender As Object,e As KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) = 13 Then
            TextBox1.Hide()
            TextBox1.Visible = False
            Spelers.Enabled = True
            cactus_plaatsen.Enabled = True
            Grond_bewegen.Enabled = True
            Punten_en_snelheid.Enabled = True
            Walk.Enabled = True
            smooth_jump.Enabled = True
        End If
        If Asc(e.KeyChar) = 27 Then
            TextBox1.Text = ""
        End If
    End Sub

    Private Sub TextBox1_KeyDown(sender As Object,e As KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyValue = Keys.Escape Then
            Me.Close()
            Form3.Show()
        End If
        If PictureBox4.Top >= 90 Then
            If e.KeyValue = Keys.Space Or Keys.Up Then
                speed = 3
                up = True
                Walk.Enabled = False
                PictureBox4.Image = My.Resources.dino_spring
            End If
        End If
        If PictureBox4.Top <= 76 Then
            If e.KeyValue = Keys.Down Then
                smooth_jump.Enabled = False
                speed = 5
            End If
        End If
    End Sub
End Class
quanlong123456 回答:阅读行的特定部分

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3159414.html

大家都在问