Jump to content

Advanced Notepad in VB 2008

- - - - -

  • Please log in to reply
33 replies to this topic

#1
mendim.

mendim.

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,393 posts
Hello CodeCall ..

Today i'm Gonna show how to make an advanced Notepad in Visual Basic 2008 Express Edition ...

The Notepad will look like this photo ..
Posted Image

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 ..

Posted Image

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 ..

Posted Image

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

Posted Image

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 ..

Posted Image

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 ..

Posted Image


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]

Attached Files



#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Very neat! +rep

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Nice job. It's things like this that make languages meaningful :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
Good tutorial, +rep.

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


#5
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Stunned, VB is sure really good language, also good work mendim !
Posted Image

#6
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
The .NET Framework, and all languages in general that target it are stunning.
*Gets gun out to shoot C/C++/Assembly code purists*

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


#7
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

Termana said:

The .NET Framework, and all languages in general that target it are stunning.
*Gets gun out to shoot C/C++/Assembly code purists*

Lol, :)
Posted Image

#8
mendim.

mendim.

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,393 posts
Thanks from all .. :)
Mendim.

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I see you are using a long-winded FileOpen(). Why not just use IO.File.WriteAllText() or go a little more precise and use an IO.StreamWriter?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
mendim.

mendim.

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,393 posts
huhu , don't understand nothing .. :s ..

#11
Martin_kp

Martin_kp

    Learning Programmer

  • Members
  • PipPipPip
  • 60 posts
This code:

mendim. said:

2.For the REDO code is :

    RichTextBox1.Undo()

It's wrong. shouldn't it be:

    RichTextBox1.Redo()

???

#12
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
Martin_kp is right.
mendim - What Xav is saying is there was a shorter way to write and read to a file using other built-in classes provided by the .NET Framework.

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users