Visual Basic Concepts

Running Code Examples from Help

See Also

Many of the language topics in Help contain code examples that you can run from Visual Basic. The following procedures show you how to copy and run a code example from Help.

Note   The following procedure is for code examples that do not contain public declarations.

To copy a code example from Help

  1. Create a new form by choosing Add Form from the Project menu, or use an existing form. (For more information on creating and using forms, see "Developing An Application in Visual Basic.")

  2. Choose Index from the Help menu.

  3. In Help, search for graphics, and go to the topic called "FillColor Property."

  4. In the FillColor Property topic, click the Example jump, located in the nonscrolling region near the top of the window. (A jump is a word that you can click to go to another topic. Jumps are underlined and the jump text is colored.)

    Select the Sub portion of the example. Note that the first "Sub" marks the beginning of the procedure and the last "End Sub" marks the end of the procedure.

  5. Right-click the selected text and select Copy from the context menu. The text is copied onto the Clipboard.

  6. Return to the form you created and double-click the form to display the Code window.

  7. Place the insertion point below any existing code in the Code window.

  8. From the Edit menu, choose Paste. The example now appears in the Code window.

  9. From the Run menu, choose Start, or press F5.

  10. Click the form to run the example code.

    Note   Some code examples require you to draw controls on the form. For more information on drawing controls, see "Forms, Controls, and Menus."