Hello, i'm working on a simple program where i can enter a name and number and it will save it to notepad .txt file. I have everything figured out up until actually saving the text i enter. what code do i use to do this, in the program i have a "is this correct?" last question with a yes or no button answer, when the user clicks yes i want the program to take textbox1.text and maskedtextbox1.text and write it to a .txt file. Is this even possible? here's the "yes" button code.

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Visible = False
        Button2.Visible = False
        Label5.Visible = False
        Label3.Text = "Your information has been saved."
        Label4.Text = ""
       

    End Sub

Just to create or overwrite a .txt file, try the following code.

Button1.Visible = False
        Button2.Visible = False
        Label5.Visible = False
        '/////////////////////////////
        Dim myCoolFile As String = "C:\myCoolTestFile.txt" '// your file location.
        IO.File.WriteAllText(myCoolFile, TextBox1.Text & " / " & MaskedTextBox1.Text) '// save to file.
        '/////////////////////////////
        '// display confirmation AFTER saving the file.
        Label3.Text = "Your information has been saved."
        Label4.Text = ""
Comments
Great thanks

If your wanting something that would not overwrite the txt file everytime (like keeping a logfile of events in your application):

Dim myfile As String = "C:\log.txt"
	   Dim itxt As New TextBox
            If IO.File.Exists(myfile) Then
                itxt.Text = IO.File.ReadAllText(myfile)
            End If
            Dim vt As String = vbCrLf & Date.Now & " - " & My.Application.Info.Version.ToString & "--" & TEXT HERE OR TEXTBOX.TEXT & My.User.Name & itxt.Text
            My.Computer.FileSystem.WriteAllText(myfile, vt, False)
            itxt.Clear()

You can also put in "Date.Now" around my.user.name as a date stamp for the logfile.

hi msrd
your code give me an error saying
Conversion from string "
06/09/2013 12:42:47 - 1.0.0.0-" to type 'Long' is not valid.
how can i troubleshoot it

This question has already been answered. Start a new discussion instead.