空白仍在添加到文件中

时间:2018-04-18 21:12:04

标签: whitespace

当我向文件添加信息时,它会做得很好。它会错误地检查字段,但最后会在文件中添加空格。 如果字段保持空白,也会发生这种情况。

Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        If Char.IsNumber(txtStudentID.Text) = False Then
            MessageBox.Show("Text cannot include letters or be clear, fill in  correctly before proceeding",
                            "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtStudentID.Clear()
            txtStudentID.Focus()
        Else
            OneMember.StudentID = txtStudentID.Text
        End If

        Char.IsLetter(txtName.Name)
        If Char.IsLetter(txtName.Text) = False Then
            MessageBox.Show("Text cannot include number or be clear, fill in  correctly before proceeding",
                            "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtName.Clear()
            txtName.Focus()
        Else
            'OneMember.NameOfStudent = txtName.Text
        End If



        Char.IsLetter(txtLesson.Name)

        If Char.IsLetter(txtLesson.Text) = False Then
            MessageBox.Show("Text cannot include number or be clear, fill in  correctly before proceeding",
                            "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtLesson.Clear()
            txtLesson.Focus()
        Else
            'OneMember.Lesson = txtLesson.Text
        End If


        Char.IsNumber(txtPayed.Text)

        If Char.IsNumber(txtPayed.Text) = False Then
            MessageBox.Show("Text cannot include letters or be clear, fill in  correctly before proceeding",
                            "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            txtPayed.Clear()
            txtPayed.Focus()
        Else
            OneMember.AmountPayed = txtPayed.Text
        End If

        OneMember.NameOfStudent = txtName.Text
        OneMember.Lesson = txtLesson.Text
        OneMember.DOl = txtDate.Text
        OneMember.TOL = txtTime.Text
        FileOpen(1, AddLesson, OpenMode.Random, , , Len(OneMember))
        NumberOfRecords = LOF(1) / Len(OneMember)
        FilePut(1, OneMember, NumberOfRecords + 1)
        FileClose()
        NumberOfRecords = NumberOfRecords + 1
        txtStudentID.Clear()
        txtName.Clear()
        txtDate.Clear()
        txtTime.Clear()
        txtLesson.Clear()
        txtPayed.Clear()
        MsgBox(" Student added to file")
    End Sub

0 个答案:

没有答案