Visual Basic 2008 - Advanced Notepad. I Just remade my video on How to make a text editor in visual basic 2008 and made it it better and easier to understand. This is a tutorial on a simple Notepad which has; New, Open, Save, Font, Colour, Undo, Redo, Cut, Copy, Paste, Clear, Select All. Enjoy and here are the codes:
New:
RichTextBox1.Clear()
Open:
Try
Dim dlg As OpenFileDialog = New OpenFileDialog
dlg.Title = "Open"
dlg.Filter = "Rich Text Files (*.rtf)|*.rtf"
If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
RichTextBox1.LoadFile(dlg.FileName)
End If
Catch ex As Exception : End Try
Save:
Try
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Title = "Save"
dlg.Filter = "Rich Text Files (*.rtf)|*.rtf"
If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText)
End If
Catch ex As Exception : End Try
Undo:
RichTextBox1.Undo()
Redo:
RichTextBox1.Redo()
Cut:
RichTextBox1.Cut()
Copy:
RichTextBox1.Copy()
Paste:
RichTextBox1.Paste()
Clear:
RichTextBox1.Clear()
Select All:
RichTextBox1.SelectAll()
Colour:
Try
Dim dlg As FontDialog = New FontDialog
dlg.Font = RichTextBox1.Font
If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
RichTextBox1.Font = dlg.Font
End If
Catch ex As Exception : End Try
Font:
Try
Dim dlg As ColorDialog = New ColorDialog
dlg.Color = RichTextBox1.ForeColor
If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
RichTextBox1.ForeColor = dlg.Color
End If
Catch ex As Exception : End Try
@jibz988 Then go back to main form and double-click the 'close' item under the 'file' menu bar and encode Form2.show() . That's just it.
mariennelopez30 1 week ago
@jibz988 First create a second form with two buttons named 'yes' and 'no' and a label that says, "Do you want to exit the program without saving it?'. Then, encode the ff:
'yes' button:
End
'no' button:
Dim SaveFileDialog1 As New SaveFileDialog
Dim RichTextBox1 As New RichTextBox
SaveFileDialog1.Filter = "rtf files(*.rtf)|*.rtf|txt files(*.txt)|*.txt|All files(*.*)|*.*"
If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName)
End If
mariennelopez30 1 week ago
@keeblerelmcookies Code for print:
Dim PrintDialog1 As New PrintDialog
PrintDialog1.ShowDialog()
mariennelopez30 1 week ago
no find, replace???
ek451 2 weeks ago
Print????????
keeblerelmcookies 2 weeks ago
close???
jibz988 2 weeks ago
@super1992ism Really?I can save, Try Click Save,and name 123,Save at desktop,and open?
jacky8399 1 month ago
I make it better...
jacky8399 1 month ago
Font and Color dialog's are backwards ;)
gavinstubbs09 1 month ago