30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3 Introduction <strong>to</strong> <strong>Visual</strong> <strong>Basic</strong> <strong>Program</strong>ming 65<br />

mand window. This behavior produces a result similar <strong>to</strong> that of pressing the Enter key<br />

when typing in a text edi<strong>to</strong>r window—the cursor is repositioned at the beginning of the next<br />

line in the file. <strong>Program</strong> execution terminates when the program encounters the End Sub<br />

in line 8.<br />

Now that we have presented our first console application, we provide a step-by-step<br />

explanation of how <strong>to</strong> create and run it using the features of the <strong>Visual</strong> Studio .<strong>NET</strong> IDE.<br />

1. Create the console application. Select File > New > Project... <strong>to</strong> display the<br />

New Project dialog (Fig. 3.2). In the left pane, select <strong>Visual</strong> <strong>Basic</strong> Projects,<br />

and, in the right pane, select Console Application. In the dialog’s Name field,<br />

type Welcome1. The location in which project files will be created is specified<br />

in the Location field. By default, projects are saved in the folder <strong>Visual</strong> Studio<br />

Projects inside the My Documents folder (on the Windows desk<strong>to</strong>p). Click<br />

OK <strong>to</strong> create the project. The IDE now contains the open console application, as<br />

shown in Fig. 3.3. Notice that the edi<strong>to</strong>r window contains four lines of code provided<br />

by the IDE. The coloring scheme used by the IDE is called syntax-color<br />

highlighting and helps programmers visually differentiate programming elements.<br />

Keywords appear in blue, whereas text is black. When present, comments are colored<br />

green. In Step 4, we discuss how <strong>to</strong> use the edi<strong>to</strong>r window <strong>to</strong> write code.<br />

2. Change the name of the program file. For programs in this book, we change the<br />

name of the program file (i.e., Module1.vb) <strong>to</strong> a more descriptive name. To rename<br />

the file, click Module1.vb in the Solution Explorer window, this step<br />

will display the program file’s properties in the Properties window (Fig. 3.4).<br />

Change the File Name property <strong>to</strong> Welcome1.vb.<br />

Project<br />

name<br />

File<br />

location<br />

Left pane Right pane<br />

Fig. Fig. 3.2 3.2 Creating a Console Application with the New Project dialog.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!