Tutorial vb.net berikut ini adalah belajar cara
membuat Notepad sederhana dengan program vb.net seperti notepad buatan microsoft, yah namanya juga sederhana pasti tidak sesempurna aslinya, paling tidak kita tahu bagaimana cara membuatnya..
Notepad sederhana ini menggunakan beberapa tool yang terdapat di vb.net yaitu MenuStrip, ContextMenuStrip serta RichtTextBox.
Tutorial vb.net cara membuat Notepad sederhana dengan program vb.net :
Tutorial vb.net cara membuat Notepad sederhana dengan program vb.net :
- Langsung saja buka Microsoft Visual Basic 2010 anda.
- Muncul “Form1”, masukkan MenuStrip, ContextMenuStrip serta RichtTextBoxyang terdapat di ToolBox dengan cara double klik ToolBox yang dipilih
- Klik MenuStrip1 dan ganti menu seperti di bawah ini dengan mengklik “Type Here” pda MenuStrip1
- Klik ContextMenuStrip dan ganti menu seperti di bawah ini dengan mengklik “Type Here” pada ContextMenuStrip
- Ubah Propertiesnya seperti ini :
Nama Control Properties Nilai Form1 Text Notepad Maximizebox False 7. Setelah itu masukkan kode berikut ini :Public Class Form1Private Sub BaruToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BaruToolStripMenuItem.ClickRichTextBox1.Text = “”End SubPrivate Sub BukaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BukaToolStripMenuItem.ClickDim kotak_dialog As OpenFileDialog = New OpenFileDialogkotak_dialog.Filter = “Text (*.txt)|*.txt”kotak_dialog.ShowDialog()Dim FileText As String = My.Computer.FileSystem.ReadAllText(kotak_dialog.FileName)RichTextBox1.Text = FileTextEnd SubPrivate Sub SimpanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpanToolStripMenuItem.ClickDim kotak_dialog As SaveFileDialog = New SaveFileDialogkotak_dialog.Filter = “Mainkan Musiknya (*.txt)|*.txt”kotak_dialog.ShowDialog()My.Computer.FileSystem.WriteAllText(“” & kotak_dialog.FileName & “”, RichTextBox1.Text, False)End SubPrivate Sub RegulerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegulerToolStripMenuItem.ClickRichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular)End SubPrivate Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.ClickDim color_dialog As ColorDialog = New ColorDialogcolor_dialog.ShowDialog()RichTextBox1.SelectionColor = color_dialog.ColorEnd SubPrivate Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseDownIf (e.Button = Windows.Forms.MouseButtons.Right) ThenContextMenuStrip1.Show(RichTextBox1, e.Location)End IfEnd SubPrivate Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChangedEnd SubPrivate Sub BoldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BoldToolStripMenuItem.ClickRichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Bold)End SubPrivate Sub ItalicToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItalicToolStripMenuItem.ClickRichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic)End SubPrivate Sub StrikeoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StrikeoutToolStripMenuItem.ClickRichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Strikeout)End SubPrivate Sub UnderlineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnderlineToolStripMenuItem.ClickRichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Underline)End SubPrivate Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClickedEnd SubEnd Class8. 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.
0 Komentar:
Posting Komentar