Hi All,

I have written a sub routine for a Save>Menu option for a MDI Text Editor, Please see my code below

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        Dim f As Form2
        If f.Text = "Text Editor V.2 - New Document" Then
            SaveAsToolStripMenuItem.PerformClick()
        Else
            (My.Computer.FileSystem.WriteAllText, DirectCast(Me.ActiveMdiChild, Form2).RichTextBox1.Text, False)
        End If
    End Sub

From this sub routine I get a syntax error, at the start of line 6, which reads (My.Computer.Filesystem........

Now if I take out the ( I get yet another error which states

"Argument not specified for perameter "File" of public sub WriteAllText(File as string, text as string, append as boolean)

All I want is when the user clicks the save menu item the document either saves the changes made to the current document or the save as routine is involked.

Can someone please take a look at my current sub routine and tell me what I have done wrong, or suggest an alternative.

Thanks very much

John

Edited 6 Years Ago by discovery-power: n/a

it looks obvious
try this

My.Computer.FileSystem.WriteAllText( filepath , DirectCast(Me.ActiveMdiChild, Form2).RichTextBox1.Text, False)

filepath is a string (a path) which you can get out of a savedialog and assign to the richtextbox tag
you code would look like this

Dim TextEditor = DirectCast(Me.ActiveMdiChild, Form2).RichTextBox1
        If String.IsNullOrEmpty(TextEditor.Tag) Then
            If DirectCast(Me.ActiveMdiChild, Form2).SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                TextEditor.Tag = DirectCast(Me.ActiveMdiChild, Form2).SaveFileDialog1.FileName
            Else
                Exit Sub
            End If
        End If
        My.Computer.FileSystem.WriteAllText(TextEditor.Tag, TextEditor.Text, False)
This question has already been answered. Start a new discussion instead.