vb logo


Visual Basic Books
Beginner Visual Basic Books
Database Visual Basic Books
ActiveX Visual Basic Books
Advanced Visual Basic Books
VB Internet Programming Books

Visual Basic Links
Add a Link
Subscribe to Mailing List

Visual Basic Tutorial

Writing Your First Visual Basic 6 Program

The following tutorial is being provided courtesy of Microsoft Press. It has been extracted from " Microsoft Visual Basic 6.0 Professional (step by step) "

Writing Your First Program

In this lesson you will learn how to:

  • Create the user interface for a new program.
  • Set the properties for each object in your user interface.
  • Write program code.
  • Save and run the program.
  • Build an executable file.



35 min.

As you learned in Lesson 1, the Microsoft Visual Basic programming environment contains several powerful tools to help you run and manage your programs. Visual Basic also contains everything you need to build your own applications for Windows from the ground up. In this lesson, you’ll learn how to create a simple but attractive user interface with the controls in the Visual Basic toolbox. Next, you’ll learn how to customize the operation of these controls with special characteristics called property settings. Then, you’ll see how to identify just what your program should do with text-based program code. Finally, you’ll learn how to save and run your new program (a Las Vegas–style slot machine) and how to compile it as an executable file.

Lucky Seven: Your First Visual Basic Program

The Windows-based application you’re going to construct is Lucky Seven, a game program that simulates a lucky number slot machine. Lucky Seven has a simple user interface and can be created and compiled in just a few minutes using Visual Basic. (If you’d like to run a completed version of Lucky.exe before you start, you can find it in the \Vb6Sbs\Less02 folder on your hard disk.) Here’s what your program will look like when it’s finished:

Programming Steps

The Lucky Seven user interface contains two command buttons, three lucky number windows, a graphic of a stack of coins, and the label Lucky Seven. These elements were produced in the program by creating seven objects on the Lucky Seven form and then changing several properties for each object. After the interface was designed, program code for the Spin and End command buttons was added to the program to process the user’s button clicks and produce the random numbers. To re-create Lucky Seven, you’ll follow three essential programming steps in Visual Basic: creating the user interface, setting the properties, and writing the program code. The process for Lucky Seven is summarized in the table on the following page.

next page....

Email us your comments:mail
Fax: 1(916)404-7719
©1999-2000 VisualBasicBooks.com. All rights reserved.