This documentation is archived and is not being maintained.

Stealing is Okay: Samples and Starter Kits

The only thing better than writing code is not having to write code—Visual Basic 2005 makes it easy to reuse code contained in Help topics, sample applications, and Starter Kits.


If you are using Visual Basic Express Edition, some of the Help links on this page may be unavailable, depending on the options that you chose during installation. For more information, see Troubleshooting Visual Basic Express.

You may have noticed as you worked through the lessons that wherever there were blocks of code in the Help topics there were also links marked Copy Code. Clicking the Copy Code link in a Help topic copies the code in that block to the Clipboard; you can then paste it directly into the Code Editor instead of typing it.

Many Help topics contain code examples to show how you might use a particular language element, property, or function. Although they may not match exactly what you want to do, you can copy them into your code as a starting point, and then modify them to fit your needs by changing variable names and references.

Visual Basic 2005 includes a number of sample applications that can give you a head start in creating your own programs. Sample applications are complete projects that can be loaded into Visual Basic 2005 and run without modification. In most cases they aren't very useful as programs; however, they often contain a lot of useful code.

For example, the Game sample application demonstrates a simple Windows Forms game, complete with GDI+ graphics, timer features, user configuration, and high-score storage. If you are writing your own card game, the user interface code in the Game sample probably won't be of much use. However, the code for storing and displaying high scores might be very useful; you might be able to copy it and use it in your program as is.

In other cases, you might want to take the sample application and use it as a starting point, modifying and adding to it to meet your own needs. Even if the sample doesn't do exactly what you want, it is often easier than starting from scratch. For more information, see Visual Basic Express Sample Applications.

Starter Kits are similar to sample applications, but unlike most samples, they are complete applications that can be used on their own. For example, the My Movie Collection Starter Kit is a complete application for keeping track of your DVD movie collection.

Like sample applications, Starter Kits can be used as a starting point for your own program. If you want to create a program for keeping track of music files instead of movies, you can easily customize the My Movie Collection to meet your needs. Starter Kits contain suggestions for customization, along with sample code, to help you. For more information, see Starter Kits: Getting Up and Running Quickly.

After you have been programming for a while, you will probably find that you are writing the same code over and over again. For example, you might write code for a TextBox control to allow only numbers to be entered. Rather than writing the same code for every program, you can write the code once and save it by dragging it to the Toolbox. The next time you need that piece of code, you can drag it back onto the Code Editor to insert it in your code.


If you find that you are saving a lot of code to the Toolbox, you may find it difficult to find the code that you need. You can also save code as a Code Snippet and access it just like the Code Snippets that ship with Visual Basic 2005.

In addition to the code that is included in Visual Basic Express Edition, there are many other sources for obtaining code, both from Microsoft and from third parties. You can search for code snippets, templates and starter kits, samples, and controls by choosing Community Search on the Community menu. For more information, see How to: Search for Code Snippets Online.

You can also search Help to find topics that contain code. For more information, see How to: Find Topics with Sample Code.

In this lesson, you learned about several options for finding code so you don't have to write it yourself. In the next lesson, you will find out where to get in-depth information about different features of Visual Basic Express Edition.

Next Lesson: Digging Deeper: I Want to Know More About....