Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Advanced Notepad in VB 2008


  • Please log in to reply
33 replies to this topic

#1 mendim.

mendim.

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 741 posts

Posted 02 January 2009 - 03:08 PM

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

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 02 January 2009 - 03:10 PM

Very neat! +rep
  • 0

#3 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 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

Posted 03 January 2009 - 04:06 AM

Nice job. It's things like this that make languages meaningful :)
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#4 Termana

Termana

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 971 posts

Posted 03 January 2009 - 04:45 AM

Good tutorial, +rep.
  • 0

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

    ???

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1919 posts
  • Location:Sweden
  • Programming Language:C, Java, PHP, Python, Bash
  • Learning:C++, C#, JavaScript, Visual Basic .NET, Others

Posted 03 January 2009 - 04:54 AM

Stunned, VB is sure really good language, also good work mendim !
  • 0

#6 Termana

Termana

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 971 posts

Posted 03 January 2009 - 05:06 AM

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

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

    ???

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1919 posts
  • Location:Sweden
  • Programming Language:C, Java, PHP, Python, Bash
  • Learning:C++, C#, JavaScript, Visual Basic .NET, Others

Posted 03 January 2009 - 05:14 AM

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


Lol, :)
  • 0

#8 mendim.

mendim.

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 741 posts

Posted 03 January 2009 - 07:38 AM

Thanks from all .. :)
Mendim.
  • 0

#9 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 06 January 2009 - 01:10 PM

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?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#10 mendim.

mendim.

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 741 posts

Posted 06 January 2009 - 02:55 PM

huhu , don't understand nothing .. :s ..
  • 0

#11 Martin_kp

Martin_kp

    CC Regular

  • Just Joined
  • PipPipPip
  • 46 posts

Posted 06 January 2009 - 07:28 PM

This code:

2.For the REDO code is :

    RichTextBox1.Undo()


It's wrong. shouldn't it be:
    RichTextBox1.Redo()

???
  • 0

#12 Termana

Termana

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 971 posts

Posted 07 January 2009 - 02:13 AM

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

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





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download