Ubah Propertiesnya seperti ini :
Nama Control | Properties | Nilai |
Form1 | Text | Notepad |
| Maximizebox | False |
7. Setelah itu masukkan kode berikut ini :
Public Class Form1
Private Sub BaruToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BaruToolStripMenuItem.Click
RichTextBox1.Text = “”
End Sub
Private Sub BukaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BukaToolStripMenuItem.Click
Dim kotak_dialog As OpenFileDialog = New OpenFileDialog
kotak_dialog.Filter = “Text (*.txt)|*.txt”
kotak_dialog.ShowDialog()
Dim FileText As String = My.Computer.FileSystem.ReadAllText(kotak_dialog.FileName)
RichTextBox1.Text = FileText
End Sub
Private Sub SimpanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpanToolStripMenuItem.Click
Dim kotak_dialog As SaveFileDialog = New SaveFileDialog
kotak_dialog.Filter = “Mainkan Musiknya (*.txt)|*.txt”
kotak_dialog.ShowDialog()
My.Computer.FileSystem.WriteAllText(“” & kotak_dialog.FileName & “”, RichTextBox1.Text, False)
End Sub
Private Sub RegulerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegulerToolStripMenuItem.Click
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular)
End Sub
Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
Dim color_dialog As ColorDialog = New ColorDialog
color_dialog.ShowDialog()
RichTextBox1.SelectionColor = color_dialog.Color
End Sub
Private Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseDown
If (e.Button = Windows.Forms.MouseButtons.Right) Then
ContextMenuStrip1.Show(RichTextBox1, e.Location)
End If
End Sub
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
End Sub
Private Sub BoldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BoldToolStripMenuItem.Click
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Bold)
End Sub
Private Sub ItalicToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItalicToolStripMenuItem.Click
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic)
End Sub
Private Sub StrikeoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StrikeoutToolStripMenuItem.Click
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Strikeout)
End Sub
Private Sub UnderlineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnderlineToolStripMenuItem.Click
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Underline)
End Sub
Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked
End Sub
End Class
8. Setelah itu klik “Start Debugging (F5)”
9. Maka akan tampil Notepad sederhana seperti tampilan berikut ini :
~ Klik File maka akan tampil menu: Baru, Buka, Simpan
~ Ketikan Kata atau tulisan di dalam textbox dan blok tulisan tersebut, setelah itu klik kanan maka akan ada pilihan Regular, Bold, Italic, Strikeout, Underline dan juga color.