jboy012000
New member
Hi All,
I have written an MDI text editor, its almost complete, but I cant get the save as menu option to work correctly.
Please see my code so far.
So whats happening is that it opens the dialog ok, saves the document to my chosen location correctly, but opens a new document and gives the new document my chosen file name and leaves my saved document with the file name New Document.
But when I close all the open screens and then re-open my saved document its all as it should be.
Can someone take a look at my code and tell me where its going wrong.
Thanks very much
John
I have written an MDI text editor, its almost complete, but I cant get the save as menu option to work correctly.
Please see my code so far.
HTML:
'This sub routine controls the save as menu option
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
Dim SaveAs As New SaveFileDialog()
SaveAs.Filter = "Plain Text Files(*.txt)|*.txt"
SaveAs.Title = "Save As"
SaveAs.ShowDialog()
Try
cform = New Form2
i += 1
cform.Text = SaveAs.FileName + " - Text Editor V.2"
CF = SaveAs.FileName
cform.MdiParent = Me
cform.Show()
My.Computer.FileSystem.WriteAllText(SaveAs.FileName, (DirectCast(Me.ActiveMdiChild, Form2).RichTextBox1.Text), False)
Catch ex As Exception
End Try
End Sub
So whats happening is that it opens the dialog ok, saves the document to my chosen location correctly, but opens a new document and gives the new document my chosen file name and leaves my saved document with the file name New Document.
But when I close all the open screens and then re-open my saved document its all as it should be.
Can someone take a look at my code and tell me where its going wrong.
Thanks very much
John