Today i'm Gonna show how to make an advanced Notepad in Visual Basic 2008 Express Edition ...
The Notepad will look like this photo ..

Let's Start ..
Create a Project
Increase the Size of Form1 and Rename with " Your Name.. Notepad "
Make a Rich Text Box and size like in photo ..

As u see in photo u need a little Space There ...
After That you should create some Menu Strips In The Little Space that you let in the picture Above ..
These Menu Strips will look like this ..

The menu Strip with the name File , make like this photo ..

So Let's Work here ..
1.Code For the menu Strip named NEW will be ..
RichTextBox1.Text = ""
2.Code for the menu Strip named Open we should add an OPENFILEDIALOG from ToolBox and the code is
Dim AllText As String = "", Lineoftext As String = "" OpenFileDialog1.Filter = "All Files |*.*" OpenFileDialog1.ShowDialog() If OpenFileDialog1.FileName <> "" Then End If Try FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input) Do Until EOF(1) Lineoftext = LineInput(1) AllText = Alltext & LineOftext & vbCrLf Loop RichTextBox1.Text = AllText Catch Finally FileClose(1) End Try
3.For the menu Strip named SAVE we should add an SAVEFILEDIALOG from ToolBox and the code is
SaveFileDialog1.Filter = "TextDocuments |*.txt |All Files|*.*" SaveFileDialog1.ShowDialog() If SaveFileDialog1.FileName <> "" Then FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output) PrintLine(1, RichTextBox1.Text) FileClose(1) End If
4.For the menu Strip named PRINT add a PRINT DIALOG from toolbox and the code is
Dim AB As New PrintDialog Try AB.ShowDialog() RichTextBox1.Text = AB.PrintToFile Catch ex As Exception 'Again, do nothing on exception End Try
5.For the menu Trip EXIT code is
End
after that just Add a Numeric UpDown (no in the RichTextBox)..
Now let's go to the menustrip EDIT that looks like this ..

1.For the UNDO code is
RichTextBox1.Undo()
2.For the REDO code is :
RichTextBox1.Undo()
3.For the CUT code is :
RichTextBox1.Cut()
4.For the COPY code is :
RichTextBox1.Copy()
5.For the PASTE code is :
RichTextBox1.Paste()
6.For the SELECT ALL code is:
RichTextBox1.SelectAll()
7.For the CLEAR ALL code is :
RichTextBox1.Text = ""
Go To the menustrip named FORMAT that will look like this ..

1.For the menustrip named FONT add a FONTDIALOG and the code is
Dim FS As New FontDialog Try FS.ShowDialog() RichTextBox1.Font = FS.Font Catch ex As Exception 'Do nothing on exeption End Try
2.For the menustrip named COLOR adda a COLORDIALOG from toolbox , code is
Dim FC As New ColorDialog Try FC.ShowDialog() RichTextBox1.ForeColor = FC.Color Catch ex As Exception 'Again, do nothing on exception End Try
...
Finally , Test it ..
Best Wishes ,
Mendim.
[ATTACH]1209[/ATTACH]


Sign In
Create Account



Back to top










