VB.net一种向每一行添加一个speciefied String的方法

时间:2015-10-28 11:34:55

标签: vb.net streamwriter

我正在编写一个程序,它有一个带有许多Textfields和Comboboxes的Mask。直到现在一切都工作正常,但我想让它更容易,并在行的末尾添加一个单词,这将帮助我稍后识别每行的输出。那是streamWriter代码

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Dim Save As New SaveFileDialog()
    Dim myStreamWriter As System.IO.StreamWriter
    Save.Filter = "Text [*.txt*]|*.txt|All Files [*.*]|*.*"
    Save.CheckPathExists = True
    Save.Title = "Save File"
    Save.ShowDialog(Me)
    Try
        myStreamWriter = System.IO.File.AppendText(Save.FileName)
        myStreamWriter.WriteLine(TextBox1.Text)
        myStreamWriter.WriteLine(TextBox4.Text)
        myStreamWriter.WriteLine(ComboBox6.Text)
        myStreamWriter.WriteLine(ComboBox5.Text)
        myStreamWriter.WriteLine(TextBox3.Text)
        myStreamWriter.WriteLine(TextBox5.Text)
        myStreamWriter.WriteLine(TextBox6.Text)
        myStreamWriter.WriteLine(TextBox7.Text)
        myStreamWriter.WriteLine(TextBox8.Text)
        myStreamWriter.WriteLine(TextBox9.Text)
        myStreamWriter.WriteLine(TextBox11.Text)
        myStreamWriter.WriteLine(TextBox10.Text)
        myStreamWriter.WriteLine(TextBox12.Text)
        myStreamWriter.WriteLine(TextBox2.Text)
        myStreamWriter.WriteLine(TextBox13.Text)
        myStreamWriter.WriteLine(TextBox14.Text)

        myStreamWriter.Flush()
    Catch ex As Exception
    End Try
End Sub

那就是我得到的输出txt文件:

Looks Like

Wannt to look like

我知道你可以帮助我们。

1 个答案:

答案 0 :(得分:0)

myStreamWriter.WriteLine(TextBox13.Text&“”&“这是序列号”)