tags:

views:

37

answers:

1

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)
A: 

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.

The King
The writeline works nice thanks.
Some-guy
pardon me im crashcausing VBA today so \r\n is actually a spacebar?
Some-guy
\r\n is the enter key...
The King
\r = Carriage Return\n = New Line
the_lotus