I have a reg text box and just want to add the save command, I managed to figure out how to do open but save is giving me problems. I am fairly new at VB.net been coding less then a week so I need all the help you can give me. Thank you in advance and here is the code I got so far:

Dim SaveFileName As String
        Dim DidWork As Integer = SaveFileDialog1.ShowDialog()

        SaveFileName = SaveFileDialog1.FileName()
        SaveFileDialog1.Filter = "Text Files|*.txt"
        SaveFileDialog1.OverwritePrompt = True

        Dim objWriter As New System.IO.StreamWriter(SaveFileName)
        MsgBox("Text Written to file")

I am not sure what I am missing or if I am even on the right track.

Member Avatar


If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, Textbox1.Text, False)
End If

You can set the Filter and OverwritePrompt properties on the form designer.

Thank you so much for your help!