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

        System.IO.File.Create(SaveFileName)
        Dim objWriter As New System.IO.StreamWriter(SaveFileName)
        objWriter.Write(TextBox1.Text)
        objWriter.Close()
        MsgBox("Text Written to file")

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

Member Avatar for Unhnd_Exception
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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.