Zebra Notes: Open, Save, Save As, and Format with a Rich Text Box

We have created an Application called MyNotes with a rich text box, a menu with standard items, and a toolstrip. The rich text box fills the form.

Next we will write the code to implement SaveAs. There is not a corresponding button for the menu item..

  1. Continue with the MyNotes Application.
  2. Find the SaveAs item on the menu and double click to open the code view.
  3. Write the code as shown below:
  4. Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
       Handles SaveAsToolStripMenuItem.Click
    SaveFileDialog1.FileName = OpenFileDialog1.FileName 'Set opened file to default
    SaveFileDialog1.ShowDialog()
    If SaveFileDialog1.FileName <> "" Then 'They did not cancel
    RichTextBox1.SaveFile(SaveFileDialog1.FileName)
    Me.Text = SaveFileDialog1.FileName
    End If
    End Sub
  5. Click Save All SaveAllat this point and run the program.
  6. Open one of the rtf files you created, then try Save, SaveAs and Open.

Next we will write the code to implement New.

NEXT: New