开发者

Appending to new line

开发者 https://www.devze.com 2023-01-22 13:56 出处:网络
Hi i have the following code which appends a text base file knowen as a .pgp file; all works fine except that everytime i launch this app i append the text in one continual line i need the text to app

Hi i have the following code which appends a text base file knowen as a .pgp file; all works fine except that everytime i launch this app i append the text in one continual line i need the text to appned to a new line eveytime it is used.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Dim FILE_NAME As String = "C:\test.pgp"

    If System.IO.File.Exists(FILE_NAME) = True Then
        Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
        objWriter.Write("saywhat " + (TextBox1.Text) + " case idont know what that means" + (TextBox2.Text))
        objWriter.Close()
        MsgBox("CUSTOM.pgp file successfully appended")
    Else
        MsgBox("File Does Not Exist")
    End If


End Sub

secondly in the following line if i add the False vale rather then true it should (according to http://www.homeandlearn.co.uk/net/nets8p5.html) create 开发者_如何转开发a file if it dosnt exist, POPY COCK, can anyone explain what im doing wrong here?

Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)


if VB.NET you can use

objWriter.WriteLine()

If VBA Insert a line into the file.. either before or after the contents...

objWriter.Write("" & Chr(10) & Chr(13) )

In windows the \r\n pattern in a line makes a linebreak... for other OperatingSystem use appropriately.

0

精彩评论

暂无评论...
验证码 换一张
取 消