Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1
37

Chapter 2


Writing Your First Program


After completing this chapter, you will be able to:
n Create the user interface for a new program.
n Set the properties for each object in your user interface.
n Write program code.
n Save and run the program.
n Build an executable file.

As you learned in Chapter 1, “Exploring the Visual Studio Integrated Development
Environment,” the Microsoft Visual Studio 2010 Integrated Development Environment (IDE)
contains several powerful tools to help you run and manage your programs. Visual Studio
also contains everything you need to build your own applications for Windows and the Web
from the ground up.

In this chapter, you’ll learn how to create a simple but attractive user interface with the
controls in the Visual Studio Toolbox. Next you’ll learn how to customize the operation
of these controls with property settings. Then you’ll see how to identify just what your
program should do by writing 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 Microsoft Visual Basic. Here’s what your
program will look like when it’s finished:

Table of Contents


Writing Your First Program.................................. 37


Lucky Seven: Your First Visual Basic Program............................ 37
Programming Steps.................................................. 38
Creating the User Interface............................................ 38
Setting the Properties................................................ 45
The Picture Box Properties............................................ 49
Writing the Code.................................................... 52
A Look at the Button1_Click Procedure................................ 56
Running Visual Basic Applications...................................... 58
Sample Projects on Disk.............................................. 59
Building an Executable File............................................ 60
Deploying Your Application........................................... 62
One Step Further: Adding to a Program................................ 63
Chapter 2 Quick Reference............................................ 64
Free download pdf