How to Create a Notepad Program - Visual Basic 6.0

Written by robert karr
  • Share
  • Tweet
  • Share
  • Email

With a little work, you can write your own version of computer notepad software in the Visual Basic programming language. This will allow the user to enter, print and save text just as Microsoft’s Notepad program does. The application can be as basic as the one described here or more complex with additional features, creating software that is similar to a word processing program. The application uses common controls and dialogue already built into Visual Basic.

Skill level:


  1. 1

    Create a new Visual Basic 6.0 (VB6) project using the “Standard EXE” template. Click on “File” in the top VB6 menu and select “Save Project As.” The first prompt asks for a form name. Name the form “MyNotePad” and click “OK.” The next prompt asks for the project name. Name it “My Notepad” and click “OK.”

  2. 2

    Click on “Project” in the top VB6 menu and select “Components.” Scroll down the list of components until you see “Microsoft Common Dialog Control 6.0.” Click on the checkbox next to this to add this control, and then click “OK.” Double-click on this control, which should be the last item in the toolbox on the left, to add it to the form.

  3. 3

    Locate the Properties box on the right of the screen and double-click on the first item, “(Name).” Change the default name to “MyNotePad.\" Double-click on the “Caption” property and change this name to “My Note Pad.\"

  4. 4

    Double-click on the TextBox icon in the toolbox panel on the left of the screen to add this to the form. Click on the new control and use the drag handles to enlarge the TextBox to nearly the size of the form itself. Locate the TextBox control in the Properties panel on the right of the screen and make these changes:

    (Name) = MyNote Multiline = True ScrollBars = 3-Both

  5. 5

    Click “Tools” in the top VB6 menu and select “Menu Editor.” Make these changes in the Menu Editor box that opens, clicking “Next” after each of the first two menus and “Exit” after the last one as shown below:

    Caption = Print Name = mnuPrint Click “Next” Caption = Save Name = mnuSave Click “Next” Caption = Exit Name = mnuExit Click “OK”

  6. 6

    Open the Code window by clicking on “View” and then “Code” in the top level VB6 menu. Type the following lines of code exactly as they appear below:

    Sub form_load() End Sub Function SaveMyNote(MyNote As Control, CommonDialog1 As CommonDialog, Filename As String) As Boolean Dim fNum As Integer On Error GoTo ExitNow CommonDialog1.Filter = \"Text Files | *.txt\" CommonDialog1.Filename = Filename CommonDialog1.CancelError = True CommonDialog1.ShowSave Filename = CommonDialog1.Filename fNum = FreeFile() Open Filename For Output As #fNum Print #fNum, MyNote.Text GO Close #fNum SaveMyNote = True ExitNow: End Function Private Sub mnuPrint_Click() With CommonDialog1 .PrinterDefault = True .ShowPrinter Printer.Print MyNote.Text Printer.EndDoc End With End Sub Private Sub mnuSave_click() Dim Filename As String If SaveMyNote(MyNote, CommonDialog1, Filename) Then MsgBox \"Your note has been saved to \" & Filename End If End Sub Private Sub mnuExit_Click() End End Sub

  7. 7

    Press “F5” to run the program. Type whatever you like in the box and print or save it using the menu items.

Tips and warnings

  • You can add more menu items to the top of your new notepad by using the Menu Editor as in step 5 and writing the associated code. You also can use the MenuEditor to create submenus under the main options.
  • The Common Dialog Control 6.0 is included in a separate Microsoft file, COMDLG32.OCX. If you compile this program to create an application that can be installed and used by others, you must distribute this file along with the executable (EXE) file.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.