update a text after you save with save as

Hi, you have your text editor program (like notepad) can someone tell me how to update the file you made and saved with the save as dialog box

In other words you open your notepad type program write the text save the file with save as then you add more text and want to click save to update the saved file.



Answer this question

update a text after you save with save as

  • Avi Jain 10

    thank you that did it
  • Linda Call

    Heres the general idea of what you want to do.

    The project has 3 buttons (Load, Save, Saveas) and a textbox. It use a module level variable Mod_strfilename to store the filename currently being worked on. This is set by the load and used by the save. The save as will update this to whatever the saveas dialog filename property.

    Public Class Form1
    Private Mod_strFilename As String = ""

    Private Sub BtnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLoad.Click
    Dim ObjFileBrowser As New OpenFileDialog

    If ObjFileBrowser.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    Dim str_Filename = ObjFileBrowser.FileName
    TextBox1.Text = My.Computer.FileSystem.ReadAllText(str_Filename)
    Mod_strFilename = str_Filename
    End If
    End Sub

    Private Sub BtnSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSaveAs.Click
    Dim ObjFileBrowser As New SaveFileDialog

    If ObjFileBrowser.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    Dim str_Filename = ObjFileBrowser.FileName
    My.Computer.FileSystem.WriteAllText(str_Filename, Me.TextBox1.Text, False)
    Mod_strFilename = str_Filename '//Will reset the last Saved Filename to whatever was specified in saveas dialog
    End If
    End Sub

    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
    '//If no filename is current then
    If Mod_strFilename.Length = 0 Then
    BtnSaveAs_Click(sender, e) '//Call same save as process
    Else
    My.Computer.FileSystem.WriteAllText(Mod_strFilename, Me.TextBox1.Text, False) '//Save contents to current filename
    End If

    End Sub
    End Class


  • update a text after you save with save as