0% found this document useful (0 votes)
15 views

Faster Smarter Beginning Programming 1st Edition Jim Buyens download

Faster Smarter Beginning Programming by Jim Buyens is a comprehensive guide aimed at beginners who want to learn programming using Visual Basic .NET. The book covers fundamental programming concepts, syntax, and practical applications, including creating user interfaces and accessing databases. It is designed for readers with basic computer skills, providing step-by-step instructions and examples to facilitate learning.

Uploaded by

ndidzuhayron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Faster Smarter Beginning Programming 1st Edition Jim Buyens download

Faster Smarter Beginning Programming by Jim Buyens is a comprehensive guide aimed at beginners who want to learn programming using Visual Basic .NET. The book covers fundamental programming concepts, syntax, and practical applications, including creating user interfaces and accessing databases. It is designed for readers with basic computer skills, providing step-by-step instructions and examples to facilitate learning.

Uploaded by

ndidzuhayron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

Faster Smarter Beginning Programming 1st Edition

Jim Buyens pdf download

https://ebookgate.com/product/faster-smarter-beginning-
programming-1st-edition-jim-buyens/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Power Up Your Mind Learn Faster Work Smarter Bill Lucas

https://ebookgate.com/product/power-up-your-mind-learn-faster-work-
smarter-bill-lucas/

ebookgate.com

Beginning Oracle Programming 1st Edition Sean Dillon

https://ebookgate.com/product/beginning-oracle-programming-1st-
edition-sean-dillon/

ebookgate.com

Beginning Django E Commerce 1st Edition Jim Mcgaw (Auth.)

https://ebookgate.com/product/beginning-django-e-commerce-1st-edition-
jim-mcgaw-auth/

ebookgate.com

Beginning Microsoft SQL Server 2008 Programming Robert


Vieira

https://ebookgate.com/product/beginning-microsoft-sql-
server-2008-programming-robert-vieira/

ebookgate.com
Beginning Lua Programming Programmer to Programmer 1st
Edition Kurt Jung

https://ebookgate.com/product/beginning-lua-programming-programmer-to-
programmer-1st-edition-kurt-jung/

ebookgate.com

Beginning Groovy and Grails From Novice to Professional


1st Edition Jim Shingler

https://ebookgate.com/product/beginning-groovy-and-grails-from-novice-
to-professional-1st-edition-jim-shingler/

ebookgate.com

Exploring the Brazos River From Beginning to End 1st


Edition Jim Kimmel

https://ebookgate.com/product/exploring-the-brazos-river-from-
beginning-to-end-1st-edition-jim-kimmel/

ebookgate.com

Beginning Programming with Java For Dummies 3rd Edition


Barry Burd

https://ebookgate.com/product/beginning-programming-with-java-for-
dummies-3rd-edition-barry-burd/

ebookgate.com

Beginning programming with Java for dummies Fourth Edition


Barry A Burd

https://ebookgate.com/product/beginning-programming-with-java-for-
dummies-fourth-edition-barry-a-burd/

ebookgate.com
Copyright

PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399

Copyright © 2003 by Jim Buyens

All rights reserved. No part of the contents of this book may be reproduced or transmitted in
any form or by any means without the written permission of the publisher.

Library of Congress Cataloging-in-Publication Data

Buyens, Jim.
Faster Smarter Beginning Programming / Jim Buyens.
p. cm.
ISBN 0-7356-1780-5
Includes index.
1. Computer programming 2. Programming languages (Electronic computers) I. Title

QA76.6 .B87 2002


005--dc21 2002033765

Printed and bound in the United States of America.

123456789 QWE 7 6 5 4 3 2

Distributed in Canada by H.B. Fenn and Company Ltd.

A CIP catalogue record for this book is available from the British Library.

Microsoft Press books are available through booksellers and distributors worldwide. For
further information about international editions, contact your local Microsoft Corporation
office or contact Microsoft Press International directly at fax (425) 936-7329. Visit our Web
site at www.microsoft.com/mspress. Send comments to mspinput@microsoft.com.

FrontPage, IntelliSense, JScript, MSDN, Visual Basic, Visual C++, Visual C#, Visual Studio,
Windows, and Windows NT are either registered trademarks or trademarks of Microsoft
Corporation in the United States and/or other countries. Other product and company names
mentioned herein may be the trademarks of their respective owners.

The example companies, organizations, products, domain names, e-mail addresses, logos,
people, places, and events depicted herein are fictitious. No association with any real
company, organization, product, domain name, e-mail address, logo, person, place, or
event is intended or should be inferred.

Acquisitions Editor: Danielle Bird

Project Editor: Sandra Haynes

Series Editor Kristen Weatherby


Body Part No. X08-94873

Dedication
This book is dedicated to the homeless mentally ill people of America. Why do we lavish
health care dollars on victims of other, less debilitating illnesses, while condemning these
unfortunates to the streets and gutters?

Acknowledgments
First and foremost, I'd like to thank my wife Connie, my daughters Lorrill and Lynessa, and
my son Justin for their continued love, patience, and understanding. Thanks as well to my
parents, my brothers, and their families: Harold, Marcella, Ruth, Dave, Connie, Michael,
Steven, Rick, Jenny, Matt, and Claire. Who'd have thought any of us would end up as we
are?

At Microsoft Press, thanks to Danielle Bird, who handled all the business details, and to
Kristen Weatherby, Dick Brown, and Wendy Zucker, who helped with initial planning.
Thanks especially to Sandra Haynes, who as project editor kept the project on track and
unified through completion.

Thank you also to Tempe Goodhue and all the other people at nSight who transformed a
raw manuscript into the finished book before you now.

Most of all, thanks to you, the readers, who make an effort such as this one both possible
and worthwhile. I hope the book meets your expectations and that we meet again.
Introduction
This Book Could Be for You
System Requirements
Support

Chapter 1. Introducing Basic Concepts


How Program Code and Data Occupy Memory
Appreciating Data Types
High-Level Languages
The Concept of Layered Software
Structured Programming Constructs
Top-Down Design
Subroutines and Functions
Processing Events
Classes and Objects
Key Points

Chapter 2. Introducing Microsoft Visual Basic .NET


Preparing Your System
Obtaining Visual Basic .NET
Installing Visual Basic .NET
Easing into Visual Basic .NET
Manipulating Visual Studio Windows
Help, More Help, and Beyond Help
Understanding Visual Basic .NET Syntax
Writing and Running Your First Program
Key Points

Chapter 3. Using Elementary Statements


Using Data Types
Using Literals
Using Variables
Using Constants
Option Explicit and Option Strict
Working with Arrays
Scoping Out Variables
Writing Decision Statements
Writing Loops
Example: Writing a Tape Calculator
Key Points

Chapter 4. Using Operators and Expressions


Introducing Operators
Forming Expressions
Using Arithmetic Operators
Using Assignment Operators
Using Comparison Operators
Getting It Together with Concatenation Operators
Using Logical Operators
Using Bitwise Operators
Using Miscellaneous Operators
Testing Operators and Expressions
Key Points
Chapter 5. Using Functions and Subroutines
Introducing Functions and Subroutines
Coding Your Own Functions and Subroutines
Declaring Arguments
Passing Arguments by Value
Passing Arguments by Reference
Sidestepping Arguments
Specifying Return Values
Exiting Functions and Subroutines
Functions, Subroutines, Variables, and Scope
Designing Functions and Subroutines Effectively
Example: Writing a Four-Function Calculator
Key Points

Chapter 6. Using Built-In Functions


Finding Built-In Functions
Using Type Conversion Functions
Logical Functions
Manipulating Dates
Manipulating Strings
Using Array Functions
Generating Random Numbers
Example: Shuffling Cards
Key Points

Chapter 7. Creating Classes and Objects


The Deal with Objects
Example 1: Shuffling with Class
Construction and Destruction
Using Property Procedures
Using Structures
Trying Times and Exceptional Results
Example 2: Shuffling with Property Procedures
Key Points

Chapter 8. Using Classes, Modules, and Forms


Using .NET Framework Classes
Making the Most of Objects and Classes
Using Forms
Using Modules
Example: Dealing Cards
Key Points

Chapter 9. Designing and Using Windows Forms


Designing User Interfaces
Setting Form and Control Properties
Using Message Boxes
Finding and Creating Icons
Example: Creating a Picture Viewer
Key Points

Chapter 10. Interacting with Windows Form Controls


Form Control Categories
Adding and Arranging Form Controls
Working with Control Properties
Working With Text Boxes, Check Boxes, and Radio Buttons
Working with List Boxes
Responding to Windows Form Control Events
Example: Reporting Crocodiles
Key Points

Chapter 11. Accessing Databases


SQL Concepts and Syntax
Introducing ADO.NET
Displaying and Updating a Database
Key Points

Chapter 12. Programming Web Forms


Introducing the Web
Creating Web Projects
Examining a New ASP.NET Web Application
Designing Web Forms
The Life Cycle of an ASP.NET Page
Adding Controls to a Web Form
Responding to Web Form Events
Exchanging Data with the Web Visitor
Testing Your Web Project
Example: Date Evaluator
Key Points
For…Next

About the Author


Introduction
This Book Could Be for You

System Requirements

Support
This Book Could Be for You
If you're an experienced PC user who's never delved into programming but now has the
itch, this is the book that will get you started. It presumes you're proficient with Windows
and Windows applications, but that you wouldn't know a line of code if it came up and bit
you on the, uh, byte.

Chapter 1 explains the fundamental concepts behind all computer programming: the way
computers store instructions in memory, the way they store data in memory, and the three
logical constructs which, in combination, can express any procedure the human mind can
conceive.

Of course you want to see how these concepts appear in programming statements, which
requires a programming language to use an as example. In the case of this book, that
language is Visual Basic .NET. Visual Basic traces its roots to the original BASIC language
that John Kemeney and Thomas Kurtz developed in 1964 for teaching programming at
Dartmouth College, and it's still one of the easiest programming languages to learn. It's also
part of more Microsoft products than any other component, and it will serve you in good
stead for writing macros, product extensions, and almost anything else not built into the
products themselves.

Chapter 2 explains the fundamentals of Visual Basic .NET: how to obtain it, how to install it,
and how to enter programming statements. Chapter 3 explains elementary data types and
statements. Chapter 4 addresses operators and expressions, which calculate results in
somewhat the same way as spreadsheet formulas.

Modern programming would be impossible without the means to divide large problems into
smaller ones, to solve the small problems using small units of code, and finally to integrate
many small units into a finished whole. Chapters 5 through 8 therefore describe functions,
subroutines, classes, objects, modules, and forms. Each of these, in one way or another,
make small, focused blocks of code available to other parts of a program.

Chapters 9 and 10 address specific issues of designing Windows forms; that is, of
designing your own Windows user interface complete with drop-down menus, toolbars,
buttons, and all the other gadgets and gizmos you're accustomed to finding in Windows
programs. Chapter 11 introduces the topic of programming databases, and Chapter 12
concludes the book with instructions on how to construct programs that use an Internet
browser rather than a Windows form as the user interface.

Programmers have been writing software for more than 50 years now, and even though the
job gets easier with each new generation of tools, it remains an intricate and exacting task.
Don't expect this book to make you a practiced or professional programmer, but do expect it
to make you a fledgling one. From that starting point, you can pursue whatever direction
your needs and interests demand.

System Requirements
Although you can profitably read this book without working the examples, truly learning to
program—like learning to swim—requires physical practice. This, of course, means you'll
need a copy of Visual Basic .NET. This comes with all versions of Microsoft Visual Studio
.NET, and also with the stand-alone package sold as Microsoft Visual Basic .NET Standard.
The Standard product usually costs less than $U.S.100 and is sufficient for all the examples
in this book.

All .NET programming languages require the presence of the Microsoft .NET Framework
and SDK (System Development Kit). The Visual Studio .NET or Visual Basic .NET setup
program will install this for you, or you can download it free from Microsoft's Web site.
(Chapter 2 provides more detailed instructions.)

As to operating systems, you'll need Microsoft Windows 2000, Windows XP, or later. If you
want to program Web pages, as in Chapter 12, you'll also want to install Internet
Information Services (IIS)—which includes Microsoft's Web server— on your PC. This rules
out the use of Windows XP Home Edition, for which IIS isn't available. On Windows 2000,
Windows XP Professional, or later, IIS is an option under Control Panel, Add/Remove
Programs, Add/Remove Windows Components.

Support
The companion files for this book contain the source code for all the examples. To
download these files, browse http://www.interlacken.com/fsbp/ and select Request
Companion Files from the main menu. This Web location also contains links for frequently
asked questions, error corrections, and other news related to the book.

Please understand that the price of this book doesn't include any technical support or
debugging assistance from Microsoft, the author, or anyone else. The Help files that come
with Visual Basic are extensive and, once you grow accustomed to them, should answer
many of the questions that come up. Additional information is available on the Microsoft
developer network Web site at http://www.msdn.microsoft.com, on the Microsoft support
Web site at http://www.support.microsoft.com, and on usenet newsgroups such as
microsoft.public.dotnet.languages.vb.
Every effort has been made to ensure the accuracy of this book. Microsoft Press provides
corrections for books at http://www.mspress.microsoft.com/support/. If you have comments,
questions, or ideas regarding this book, please send them to Microsoft Press via e-mail to

mspinput@microsoft.com

or via postal mail to

Microsoft Press

Attn: Faster Smarter Series Editor

One Microsoft Way

Redmond, WA 98052-6399

You can also contact the author directly via e-mail (in English) at

buyensj@interlacken.com.

Please note that product support is not offered through the above addresses. To suggest
enhancements to any piece of Microsoft software, send an e-mail to

mswish@microsoft.com

or browse the Web page at

http://www.register.microsoft.com/regsys/custom/wishwizard.asp
Chapter 1. Introducing Basic Concepts
Computer software is surely one of the most intangible commodities of our time.
Nevertheless, it's also one of the most valuable. Of all the progress made during the past
50 years due to the use of computers, virtually 100 percent would have been impossible
without someone having written the necessary software. A computer without software is like
a rowboat without an oarsman: no objective, no plan, no activity, no progress.

Presumably, and for whatever reason, you've decided to learn how to write software of your
own. The particular type of software you have in mind doesn't matter too much right now;
first you need to learn the process of creating computer programs and fortunately, this is
fairly universal.

Computer programming consists mainly of devising procedures capable of producing a


given result, and then expressing those procedures in a way that the computer can
understand. People often refer to programming as both an art and a science, and for good
reason. Devising procedures that solve complex problems requires creativity, imagination,
and insight. Articulating them for a computer, on the other hand, requires strict logic and
attention to detail.

The earliest programmers created software using nothing more than paper, pencil, and
switches on the computer console. Yecch. Nowadays, programmers automate much of
their work by using existing software to create new software. In the case of this book, the
existing software is Microsoft Visual Basic .NET.

Visual Basic traces its roots to the BASIC language that John Kemeny and Tom Kurtz
invented in 1964 specifically for teaching students at Dartmouth College how to program.

Visual Basic is among the most widely used programming languages.

Visual Basic .NET is the most powerful and easiest to use version of Visual Basic ever.

Chapter 2, "Introducing Microsoft Visual Basic .NET," explains how to install Visual Basic
.NET and how to develop and run your first program. In the meantime, this chapter explains
some basic concepts that'll significantly help you understand the material in Chapter 2 and
the rest of the book.

How Program Code and Data Occupy Memory


A computer consisting of hardware only—that is, with no software—can do little more than
hum and consume electricity. To do useful work, the computer requires a series of
instructions that tell it exactly what to do; that is, the computer requires a program. The
program and the computer hardware work together like this:
• Random Access Memory (RAM) holds in place the instructions and any associated
data for use by the central processing unit (CPU).
• The CPU retrieves the instructions one by one, in order, and carries out whatever
actions they specify. For example, it might copy data from one area of memory to
another, perform arithmetic, compare one data value to another, or begin retrieving
instructions from a different part of memory.
• Input/output devices—such as disks, printers, a console, and network adapters—
provide various means of putting data into memory for processing and getting it back
out for practical use. The CPU operates these devices by executing special
instructions or manipulating special areas of memory.

Lingo

An instruction is any command that a computer's central processing unit can process
directly. The term machine instruction is slightly more specific but both terms mean
the same thing.

In modern computers, each character of memory has its own unique numerical address.
The first character in memory has an address of 0, the second character in memory has an
address of 1, and so forth. If you bought a computer with 128 bytes of memory, 0 would be
the first memory address and 127 would be the last. If, more realistically, you bought a
computer with 128 MB of memory, the last address would be (128 x 1024 x 1024) – 1, or
134,217,727.

Note

Because computers count by twos instead of by tens, they seldom use "nice" whole
numbers like 10 or 1,000,000 for anything. Instead, the computer's idea of a "nice" number
is any power of two. This is why numbers like 2, 4, 8, 16, 32, 64, 128, 256, 512, and 1024
keep popping up in any discussion regarding computers.

A given area of memory can hold either instructions or data. There's no physical difference
between memory that holds instructions and memory that holds data. When you load a new
program into memory and start running it, memory that previously contained data might
now contain instructions, and memory that previously contained instructions might now
contain data.
Figure 1-1 shows some hypothetical data and instructions loaded into memory. Each
instruction or element of data occupies one memory location. The CPU knows that after
processing each instruction, it should proceed to the next.

Figure 1-1. Computer programs are a series of instructions that the computer holds in memory
and executes one step at a time.

The diagram in Figure 1-1 is, of course, an oversimplification. The actual instruction set of a
typical CPU is much more cryptic and a single instruction or data value can occupy several
memory locations. The CPU knows how long each type of instruction is supposed to be,
and therefore how many bytes to advance before retrieving the next instruction.

Lingo

A CPU's instruction set is the collection of all instruction types it can process.

Appreciating Data Types


Virtually all CPUs have instructions suited to specific kinds of data. Here are three of the
most common:

• Integer instructions
These instructions add, subtract, multiply, divide, and otherwise manipulate whole
numbers. Typically, these numbers are 8, 16, 32, or 64 bits in size. An 8-bit integer
can hold values from 0 to 255 or from –126 to +127, depending on whether or not
one of the bits indicates positive or negative.

Note

A bit is one binary digit: that is, a one or a zero.

• Floating-point instructions

These instructions operate on numbers having three parts: a sign, an exponent, and
a mantissa. In a number such as 6.02 x 1023, the sign is positive, the exponent is 23,
and the mantissa is 6.02. In most cases, integers are better for counting things and
floating-point numbers are better for scientific calculations. Table 1-1 summarizes
the floating-point formats that Intel processors support.

Table 1-1. Floating-Point Formats on Intel Processors


Type Bits Exponent Mantissa
Bits Precision Bits Precision
Single 32 8 1038 to 10-44 23 6–7 decimal digits
Double 64 11 10308 to 10-323 52 15–16 decimal digits

• String instructions

These instructions operate on character data such as natural language text. On older
computers, each character of text occupies 1 byte (8 bits) of memory. On newer
systems, each character occupies 2 bytes (16 bits).

The reason for having these various data types is simple: efficiency. If your data is one of
these types, the processor can carry out basic operations with a single instruction. This is
very fast. Most programming languages support additional data types for dates, times,
money, and so forth, but when you program an operation involving one of these types, the
compiler must generate a series of instructions to do the job. This shouldn't be a deterrent
toward using any data type your programming language supports, but it should be an
incentive to use the correct type in all cases.
Chapter 3, "Using Elementary Statements," explains much more about data types and how
to use them.

High-Level Languages
Nowadays, very few programmers deal directly with the individual instructions that a CPU
processes. Instead, they code procedural statements in a special notation that a piece of
software converts to machine instructions. This is much easier than coding the machine
instructions directly. Over the years, computer scientists and developers have invented
quite a few of these notations, each of which is a programming language. Programming
languages and human languages are alike in that both have nouns, verbs, statements,
punctuation, and rules governing what's correct and what's invalid. C, C++, COBOL, C#,
Forth, FORTRAN, Java, JavaScript, Pascal, Perl, Python, and Visual Basic are all
programming languages.

The lowest and most fundamental programming language of all is machine language.
Writing programs in machine language means coding every one and zero in the entire
program by hand. This is how the first programmers worked, but hardly anyone does this
anymore. It's just too time consuming and error prone.

An assembly language is one with statements that correspond one-to-one with machine
instructions. You write assembly language with a text editor, specifying cryptic
abbreviations and decimal numbers rather than ones and zeroes. Also, in assembly
language you can refer to locations in your program by name rather than by memory
address. To run an assembly language program, you must save it as a text file and then
convert it into machine language using a program called (what else?) an assembler. This is
a huge improvement over coding machine language, but still quite time consuming and
error prone. Also, if you want to run the same program on several different kinds of
computers, you're out of luck. Assembly language programs are inexorably tied to a single
type of CPU.

High-level languages have no relation to the instruction set of a specific CPU. Instead,
they're designed primarily for ease in expressing whatever solution you've devised for the
task at hand. C, C++, C#, JavaScript, Perl, and Visual Basic are all high-level languages.

Programs called compilers translate code from high-level languages to machine language.
One high-level language statement typically results in several machine instructions. If
compilers for the same language are available for different CPU types and operating
systems, then running the same program on several different kinds of computers is a real
possibility. Nearly all modern programming involves high-level languages.

High-level languages can be either procedural or nonprocedural. Using a procedural


language, you must figure out the steps necessary to make the programs do what you
want. In other words, your source code must supply a procedure for solving the problem.
The term third-generation language (3GL) denotes a procedural high-level language. Visual
Basic is primarily a 3GL: that is, a procedural high-level language.

Note

Historically, machine language was the first generation and assembly language was the
second. However, no one used these terms until 3GLs came about.
Nonprocedural high-level languages don't require that you figure out procedures to
accomplish your objectives. Instead, you specify what kinds of results you want and the
high-level language figures out how to produce it. The terms fourth-generation language
(4GL) and specification-oriented language both denote procedural high-level languages.
The report writer feature of Microsoft Access is a 4GL, as is that of Crystal Reports. Visual
Basic .NET includes graphical form designers for both interactive Windows applications and
for Web pages; these designers, although not full 4GLs, are at least fourth-generation
features.

Note

Although 4GLs provide more automation than 3GLs, they're less flexible, and this can lead
to difficulty. The more you want to customize the results, the more you end up fighting or
bypassing the 4GL.

Second-, third-, and even some fourth-generation languages require that you enter
statements in an ordinary text file. Learning the format of these statements is a major part
of learning to program, but generically they constitute your source code. The file that
contains your source code is, of course, a source file. The assembler or compiler reads the
source file and, if all goes well, produces an executable file, a file that the computer can
load into memory and run.

Note

Many compilers and assemblers actually produce a sort of intermediate file called an object
file. A program called a linker combines the object file with other prewritten software to
produce the final executable. In most cases, however, the compiler runs the linker
automatically, and you don't need to be aware of it.

Programmers tend to use the terms code, source code, statements, and source statements
interchangeably. If someone asks to see your code, it means they want to look at your
source statements.

Each line of text in a source file is one line of code. Experienced programmers usually code
each program statement on a separate line but this isn't a hard and fast requirement. In
most programming languages (as in most natural languages) one statement can span
several lines and one line can contain several statements.

There are three fundamental types of statements:

Data declarations

These statements reserve areas of memory for use by data items. They also give the
data item a name and specify its type: integer, floating point, string, and so forth.

Note

The word variable is another name for a named data item.


Executable statements

These statements cause things to occur while the program is running. For example,
they perform arithmetic, evaluate decisions, execute loops, and get data into and out
of the program.
Control statements

These statements provide information that the compiler uses while converting source
statements to machine instructions. Unlike data declarations and executable
statements, control statements directly add nothing to the final machine language
program.

Tip

As you gain programming experience, you'll no doubt acquire the habit of


formatting source statements so they're easily readable. This greatly improves
the quality of life for you or anyone else who works on the program in the future.

One of the most important features of high-level languages, from second-generation


assemblers on up, is that you can refer to memory locations by name rather than by
number. The compiler then assigns numeric addresses to each name automatically. This
has two advantages:

• When you put some piece of information, such as your birth date, in memory, it's
much easier to refer to that data element by means of a name (like Birth_Date) than
by means of a memory address (such as 1785423).

If you rearrange or otherwise modify your program, the compiler will figure out where your
named data items end up and automatically assign new addresses to them.

You can name memory areas that contain instructions as well as memory areas that
contain data.

The Concept of Layered Software


Early programmers, using machine language or assembler, wrote completely self-sufficient
programs. As time passed and software became more complex, however, these monolithic
programs became increasingly impractical. For one thing, with each program taking over
the entire computer, it wasn't possible to run several programs at the same time. For
another, the programs grew so large and complex that they nearly defied human
understanding. Finally, many functions inside these large programs were essentially the
same. There was no point in rewriting them for each program.

These are just a few of the reasons that operating systems exist. Today, most programs
expect to run within the confines of an operating system such as Microsoft Windows and for
the operating system to provide a variety of services that the program can use. One way of
expressing this relationship is to say that programs run on top of Windows. Another way is
to talk about an operating system layer and an application layer.

In fact, operating systems and applications both have layers within themselves. Every time
one piece of software provides services and another piece of software uses them, you can
speak of a layer existing between them. In general, you don't need to be concerned about
how software at layers other than your own actually does its job. If, for example, you want
Windows to open a file, read a few records, and then close it, you needn't concern yourself
with details of how Windows does this. You only need to know how to request the service
and retrieve the results.

Lingo

An application programming interface (API) is a mechanism through which software at one


layer communicates with software at a different layer.

The Microsoft .NET initiative introduces a major new layer between applications and the
operating system, namely the common language runtime (CLR) shown in Figure 1-2. When
you compile a .NET program, the compiler doesn't produce executable code that uses the
computer's native instruction set. Instead, it produces code in a format called Microsoft
intermediate language (MSIL). The first time a .NET program runs on a given computer, the
CLR compiles the MSIL code into the computer's native instruction set.

Figure 1-2. The CLR is a .NET layer situated between application programs and the operating
system.

Here are some of the advantages that the CLR provides:

• The same ILC program can run on any processor or operating system for which a
CLR is available. This provides a migration path from Pentium processors to the
Itanium chip and the StrongARM processor in a Pocket PC.
• The CLR can perform memory management and other services that increase the
reliability of both the application and the operating system.
• All programs that use the CLR use the same data types and the same interfaces to
the operating system. This makes it much easier for programs written in different
languages to interact.

Because Visual Basic .NET creates intermediate language code, any programs you write
will only run on computers that have the Microsoft .NET Framework installed. (The .NET
Framework includes the CLR). Furthermore, the framework is currently available only for
Microsoft Windows 2000, Windows XP, and Windows .NET Server. If you or your users are
still running Microsoft Windows NT, Windows Millennium Edition (Windows Me), Windows
98, or Windows 95, now is the time to consider an upgrade.

Note

If not already, then in the very near future, virtually all Windows software will be .NET
software. The CLR will then be ubiquitous.

Structured Programming Constructs


Imagine a plate of spaghetti noodles, cooked and well tossed. Given enough time, you
could draw a map showing where each strand begins and ends, but what a task! You might
die of old age before you finished, even assuming the noodles never shifted around or grew
brittle and cracked.

Believe it or not, programmers used to create programs using logic as convoluted as that
plate of spaghetti. When it worked it was a miracle and when it didn't you either had job
security for life or plenty of incentive to look for a new job.

Lingo

To this day, spaghetti code means source code so haphazard and disorganized that almost
no one can understand it.

A technique called structured programming goes a long way toward preventing this sort of
mess. The key concept is that you can write any program using only these three kinds of
logical structures:

• Sequence

The computer will execute a group of statements in order. The statements in Figure
1-1 earlier in this chapter constitute a sequence.
• Decision

The computer will execute either one group of statements or another depending on
some condition.

• Loop

The computer will execute a group of statements repeatedly until some condition is
satisfied.

Figure 1-3 illustrates a decision. If today is Sunday, the procedure calls for visiting relatives;
otherwise, it calls for going to work. In Visual Basic, you would code this as shown here:

If Weekday(Now()) = vbSunday Then


Visit_Relatives
Else
Drive_To_Work
End If

Note

In Visual Basic .NET, Now() is a built-in function that returns the current date and time.
Weekday() is a built-in function that converts a date and time to a day-of-the-week code.
The expression vbSunday is a built-in constant that always contains the day-of-the-week
code for Sunday.

Figure 1-3. This flowchart illustrates a simple decision structure.

Both the If and the Else portions of a decision structure can contain zero statements, one
statement, or several statements. Furthermore, these statements needn't be simple
sequences; they can also be decisions or loops. For example, here's a decision structure
that contains zero statements in the Else portion:
If Weekday(Now()) = vbSunday Then
Visit_Relatives
End If

The next example shows nested decision structures; that is, one decision structure inside
another. A corresponding flowchart appears in Figure 1-4.

If Weekday(Now()) = vbSaturday Then


Clean_Yard
Wash_Car
If Month(Now()) > 8 Then
Watch_Football
End If
Else
If Weekday(Now()) = vbSunday Then
Visit_Relatives
Else
Drive_To_Work
End If
End If

Figure 1-4. The procedure in this flowchart contains decisions within decisions, which is
perfectly acceptable.
Note that in the previous code, the Else and End If for each decision appear directly
beneath the corresponding If. Statements subordinate to an If or Else appear indented to
the right. This alignment and indentation makes the code easy to read and easy to work
with; easier, in fact, than the traditional flowchart. Virtually all experienced programmers
indent their code this way.

Notice also that once the computer encounters an If statement, it'll always reach the End If
statement. The flow of control never wanders out of the decision structure and into another
piece of code. This sort of consistency makes structured programming so much easier to
understand.

Figure 1-5 illustrates a simple loop structure. The actions Go to sleep and Open eyes will
occur over and over again until the alarm starts ringing.

To describe this procedure in Visual Basic, you would write something like this:

Do
Fall_Asleep
Open_Eyes
Loop While Not Alarm_Ringing

Figure 1-5. A loop structure executes one or more statements repeatedly until some condition is
true.

As written, this code always falls asleep at least once, even if the alarm is already ringing.
To allow the loop to execute zero times, you would put the condition at the top of the loop
like this:

Do While Not Alarm-Ringing


Fall_Asleep
Open_Eyes
Loop

Again, note that the statement that ends the loop is aligned under the statement that starts
it. Statements within the loop are indented to the right. This makes it easy to see at a
glance where the loop begins and ends. These conventions are quite similar to those for
decision structures.

You might wonder if loops and decision structures are permissible within loops. They are.
Here's an example (Figure 1-6 shows the corresponding flowchart.):

Do While Not Alarm_Ringing


Do While Not Asleep
Count_Sheep
Loop
Open_Eyes
If Room_Is_Cold Then
Pull_Up_Covers
End If
Loop
Figure 1-6. It's perfectly okay to code loops and decision structures inside other loops.

As with decisions, loops have only one way in and one way out. Even when you nest one
loop inside another, executing the start of a given loop inexorably leads to that loop's one
and only exit point.

Writing programs that consist solely of sequences, decisions, and loops requires a certain
discipline and mindset. You might wonder, therefore, if there's another way to get the job
done. There is, and it goes by the name branch, jump, or go to, depending on the
programming language you're using.

A branch summarily tells the computer to start executing statements from some new spot in
memory. At first this might seem to offer wonderful flexibility because you're no longer
limited to single entry and exit points. In fact, programs that jump around from one spot to
another are very difficult to get working properly in the first place and even more difficult to
keep working as the need to make changes arises. As a result, modern programming
languages no longer support branching except in a limited way; namely, you can branch to
an exit point.

If you talk with experienced programmers for very long, you'll notice that they frequently
speak about blocks of code. Sometimes the word block means any group of statements,
but more often it means all the statements between the entry point and the exit point of a
loop or decision. Why do you need to know this? Well, the limited form of branching that
modern programming languages support is that of branching to the end of a block. This is
quite handy when a statement in the middle of a block detects that running the remainder of
the block would serve no purpose or generate an error.

Figure 1-7 illustrates a loop that counts how many cards in a deck precede the seven of
clubs. The loop says to turn over the top card and then determine if it's the seven of clubs. If
it is, you exit the loop. If not, you add one to the count of cards that weren't the seven of
clubs, and then continue the loop. Of course, if you run out of cards before finding the
seven, then you also exit the loop.

Figure 1-7. This loop has multiple paths to the exit point, but still only one exit.

Branching from the middle of a loop or decision to its normal exit point often simplifies your
job as a programmer and leads to cleaner (that is, easier to understand) code. This
technique, however, is easy to abuse. If you can figure out another way of doing the same
thing, you're probably better off.
Top-Down Design
The flowcharts and code you've seen so far have all been simple. Hopefully, you
understood them at a glance. Nevertheless, at some point flowcharts and program code
grow so large and complex that no one—including the most talented and experienced
programmers—can understand them. This would present a serious problem were it not for
the concept of modular design.

The idea of modular design is to break large programs into smaller, more easily
comprehensible modules, and then work on one small module at a time. If this sounds like
a clear application of "Divide and conquer," you're right!

The design of a modular program usually begins with a so-called mainline. When you or
your intended user loads the program into memory, the mainline is the first procedure to
execute. A typical mainline

• First acquires and initializes any resources the program needs to operate:
databases, files, network connections, and so on.
• Then runs a loop that receives input and creates output until no more input remains.
• Finally releases its resources and terminates the program.

The flowchart in Figure 1-8 illustrates this process.


Figure 1-8. This flowchart illustrates the mainline flow of control in a typical program.

The block titled "Process one unit of input" is, of course, where all the interesting stuff
happens. This code for this block typically contains a series of decisions that figure out what
kind of input has arrived and what to do about it. If the purpose of the program is to update
a database, there might be three kinds of input transactions: add a record, update a record,
and delete a record. In Visual Basic, this block might look like this:

If Trans_Code = "Add" Then


Add_Database_Record
Else
If Trans_Code = "Update" Then
Update_Database_Record
Else
If Trans_Code = "Delete" Then
Delete_Database_Record
Else
Report_Invalid_Transaction
End If
End If
End If

The four statements Add_Database_Record, Update_Database_Record,


Delete_Database_Record, and Report_Invalid_Transaction call upon other blocks of code
(that is, other modules) that provide additional processing. If those modules turn out to be
large or complicated, you would implement portions of them as still more modules. The
result, if all goes well, would be a well-organized set of modules that solve a large,
complicated problem in an orderly, methodical, and easy-to-understand way. (The next
topic in this chapter, by the way, will explain how statements like Add_Database_Record
call other blocks of code in your program.)

Top-down design is the name that describes this approach to designing programs. Top, in
this case, means the most general, most obvious parts of the program. First you design the
top module (the mainline), then any subordinate modules the mainline requires, then any
modules those subordinate modules require, and so forth.

Tip

When deciding how to divide a problem into modules, try to design modules that perform
single complete functions. Modules that do only one thing are easy to understand, and
they're easy to reuse if a similar need arises again.

There's also such a thing as bottom-up design. In this mode you start by designing some
low level module—usually one that performs an important or intricate function. Next, you
write one or more modules that use that function. Then you write more and more modules
in an attempt to reach some high-level goal such as a user interface that makes the
original, intricate function easy to use.

Tip

Neither top-down nor bottom-up design is best in all cases. The best approach depends on
the specific problem you're trying to solve.

Subroutines and Functions


There are several good ways of developing modules, but the use of subroutines and
functions is among the most common and the best. Both of these structures are named
blocks of code that are, to some extent, separate and isolated from other code in the same
program.

No matter what programming language you're using, a subroutine tends to involve these
elements:

Special statements mark the subroutine's beginning and end.

The statement that marks the beginning also specifies the subroutine's name and a list of
arguments. Arguments are one of several ways that subroutines can receive input values
and send back output values.
Between its opening and closing statements, a subroutine can contain both data
declarations and executable statements.

Perhaps an example will clarify these points. The following statements define a simple
subroutine in Visual Basic:

Sub AddemUp (aintAlpha As Integer, aintBeta As Integer)


Dim intAnswer as Integer
intAnswer = intAlpha + intBeta
End Sub

Note

The Dim statement in Visual Basic reserves memory for a data item. Dim was originally an
abbreviation for Dimension, a statement that defined the size of an array. For example, Dim
X(5, 10) created a two-dimensional array 5 cells by 10 cells.

The subroutine begins with the Sub statement and ends with the End Sub statement. The
name of the subroutine is AddemUp, and it expects to receive two integer arguments:
aintAlpha and aintBeta.

Note

Many experienced programmers begin the names of variables with a one or three letter
abbreviation that identifies the variable's data type. The additional prefix a identifies a
subroutine or function argument.

The first statement inside the subroutine reserves memory of an integer data item named
intAnswer. The second statement adds the two argument values and stores the result in
intAnswer.

The arguments named aintAlpha and aintBeta are placeholders and not real data items.
The code that calls the subroutine from elsewhere in the program specifies the actual data
items that the subroutine will process. For example, if you coded

AddemUp(5, 6)
then the AddemUp subroutine would add 5 and 6. If another spot in the program called

AddemUp(2002, 3003)

then the subroutine would add 2002 and 3003. You can also specify data items as
argument values. Here's an example:

Dim intRalph As Integer


Dim intRufus As Integer
intRalph = 500
intRufus = 700
AddemUp(intRalph, intRufus)
The first two statements declare integer data items named intRalph and intRufus. The next
two statements assign the values 500 and 700 to these two variables, respectively. The last
statement calls the AddemUp subroutine, telling it to process the values in intRalph and
intRufus.

Functions work very much like subroutines except that they return a value. To appreciate
the usefulness of this, consider that when your program calls the AddemUp subroutine, it
has no way of getting the answer. Although the subroutine stores the answer in the
intAnswer variable, that variable is inaccessible outside the subroutine.

Lingo

The scope of a variable describes which portions of a program have access to a given data
item.

Function GetSum (aintAlpha As Integer, _


aintBeta As Integer) _
As Integer
Return intAlpha + intBeta
End Function

Note

Don't be thrown by the fact that the Function statement just shown spans three lines. This is
only because coding the entire statement on one line would make it too long to fit on the
page. Whenever Visual Basic detects a space followed by an underscore, it ignores the
underscore, the next line ending, and any leading spaces on the next line.

As you can see, the syntax for defining a function is very much like that for defining a
subroutine. There are only two differences:

Instead of Sub and End Sub you code Function and End Function.

You must assign a data type to the function itself. This will be the data type of the value the
function returns.

The Return statement on line 4 does three things. First, it adds the two argument values.
Next, it assigns the result to the value of the function. Finally, it exits the function. To see
how all this works together, consider the following statement, which you could code
anywhere else in the program:

intTotal = GetSum(12, 34)


When this statement runs, the GetSum function adds the argument values 12 and 34, then
returns the answer 46. The assignment operator = then stores this value in the variable
intTotal.

Lingo

An operator is a special character or word that tells the compiler to perform some operation
on one or more data items. Some common operators are addition (+), assignment (=), and
joining two strings (&).

The self-contained nature of functions and subroutines and their ability to process any
values you specify makes them perfect for any sort of processing you might need several
times in the same program or, for that matter, in several programs. You code the function or
subroutine just once and then use it many times.

Chapter 5, "Using Functions and Subroutines," has much more to say about functions and
subroutines. For now, just remember that they exist and that their purpose is dividing large
programs into smaller, easier-to-understand modules.

Note

Visual Basic uses the term module to mean a text file that contains the source code for one
or more related functions or subroutines. This usage is more specific than the general term
modular design and the general concept of modules themselves.

Processing Events
Unlike most other kinds of programs, programs that run on the Windows desktop go into a
sort of "wait state" immediately after they start up and display their main window. The
program is essentially at rest, waiting for the user to select a menu choice, click a toolbar
button, manipulate a form control, resize the window, or the like. Windows calls each of
these actions an event.

It's your job, as a programmer, to write an event handler for each event you want to
process. Suppose, for example, that your main window contains a button named Button1. If
you designate a subroutine in your program as an event handler for the Button1.Click
event, that subroutine will run whenever the user clicks that button. If your program doesn't
contain such a subroutine, clicking the button has no effect. Windows simply discards the
event.

This mode of operation can be surprising at first. Your program doesn't seem to have a
mainline at all; it just contains a bunch of event handler subroutines that you never write
code to invoke. Instead, Windows invokes them if and when the user initiates the
corresponding event.

In fact, such programs do have a mainline; it's called an event loop. Here's how this works:

The event loop receives one event.

It then tries to find an event handler.

If one exists, the event loop calls the event handler.

Otherwise, the event loop discards the event

The loop restarts at step 1.

Interesting as this is, the event loop isn't something you write yourself. Instead, it's part of
the Windows operating environment. Your role is simply to write the event handlers your
program needs and then trust Windows to run them when the necessary moment arrives.
Later chapters provide many examples of event handlers.

Classes and Objects


Just as the concepts of structured programming once revolutionized software development,
object-oriented programming (OOP) has revolutionized it again. Objects, in this sense, are
software modules that group together all the data items and procedures necessary to
represent some real or abstract entity. Suppose, for example, that you want to write
programs that manage apartment leases. Associated with each lease are

Certain data items, such as the property location, the leaseholder's name, the monthly rent,
the start date, the end date, and so forth. These are the properties of the lease.

Certain activities, such as initiating a new lease, printing it, receiving rent, creating an
overdue notice if the rent is late, canceling the lease, renewing it, and so forth. These are
the methods of the lease.

Obviously, it would be very handy to package all these properties and methods into a single
module that you could incorporate into any program that needed them. This technology
exists and the name for such a module is an object.

Curiously, though, programmers don't write objects; instead, they write classes. A class is a
template for an object but it's not an object itself. To understand this distinction, suppose
that a program needs to work with several leases at once. Perhaps it needs to work
simultaneously with all leases in the same building, for example, or all leases with the same
leaseholder. To do this, you would create one instance of the Lease class for each lease.
This is very much like filling out one lease form for each lease.
Each instance of a class (such as the Lease class) is an object (such as a Lease object).
Like a blank lease form, the class defines procedures and data structures but no specific
data values. An object, however, does contain data values unique to a particular instance,
and in this respect resembles a completed lease form. Generally the data values that
pertain to each object (that is, to each instance) of a class will differ. All objects of the same
class will, however, contain the same type of data.

Once again, an example clarifies these points. Here's some hypothetical Visual Basic code
that loads two Lease objects into memory:

Dim Lease01 As Lease


Dim Lease02 As Lease
Lease01 = New Lease(2,107)
Lease02 = New Lease(2,108)
The first two statements reserve memory for two Lease objects. The third statement creates
a Lease object that contains the current data for building 2, unit 107. The last statement
creates a Lease object for building 2, unit 108. Both objects are instances of the Lease
class. They both use the same code and the same data structures, just as two lease
contracts would use the same lease form.

To code a class in Visual Basic, you start with a Class statement and end with an End
Class statement. Between these, you code a function or subroutine for each method and
either a data declaration or a property procedure for each property. (A property procedure is
essentially a function or subroutine that runs whenever a program sets or requests a given
class property.)

Chapter 7 explains classes and objects in more detail.

Key Points
• Program code and data both reside at relatively random locations in the computer's
main memory. There's no physical difference between memory that contains
instructions and memory that contains data.
• The process of running a program is that of fetching and executing instructions from
memory in a prescribed sequence.
• Each type of processor has special instructions for dealing with data in certain
formats. Compilers generally support the same data types as the processor, plus
other types of their own.
• High-level languages are easier to use than languages that closely match the
computer's native instruction set.
• Several conceptual layers of software generally exist between application programs
and the computer hardware. The operating system and the .NET common language
runtime (CLR) are layers, and have further layers within themselves.
• The fundamental programming structures are sequences, decisions, and loops.
• You can organize and simplify the job of programming by dividing each program into
small modules, writing the main module (the mainline) first, and then writing
whatever modules the mainline requires, and so forth, for as many levels as
necessary.
• Subroutines and functions are named, free-standing blocks of code you can invoke
from anywhere else in your program and they're an excellent tool for implementing
modular design.
• Windows programs usually don't have a mainline. Instead, they contain a collection
of event handlers that respond to menu selections, button clicks, and other events in
the user interface.
• Object-oriented programming uses modules called classes that bundle together all
the data items and all the processing methods for a single conceptual entity.
Chapter 2. Introducing Microsoft Visual Basic .NET
By its very nature, computer programming involves a myriad of highly interrelated concepts.
This creates a very real problem for people learning to program, because you can't really
understand one concept without understanding several others. And you can't understand
those without understanding the first one.

People have struggled with this problem for years and inevitably, the best solutions involve
learning by doing and learning incrementally. Learning by doing means that to learn
programming, you must write programs. This in turn means that you need a programming
language to learn with and—in the case of this book—that's Microsoft Visual Basic .NET. A
large part of this chapter explains how to obtain and install Visual Basic .NET. The chapter
continues with a bit of instruction on how to write Visual Basic .NET statements and
concludes with step-by-step instructions for writing your first program.

Learning incrementally means that first you learn a little about several topics, then more
about those topics, and so forth, in ever-increasing levels of detail. That's why, in the case
of reading this book, you're likely to notice many of the same topics coming up repetitively.
You're also likely to find missing ends and dangling issues after each discussion. To some
extent this never ends; programmers and computer scientists with decades of experience
are still learning nuances and refining techniques. To another extent, it means there's a
reason to finish reading the book.

Preparing Your System


The information in this section explains the software and hardware requirements for
developing applications in Visual Basic .NET. There are two quite different kinds of .NET
applications—Windows and Web—each with requirements you need to consider
separately.

Preparing for .NET Windows Applications

Visual Basic .NET programs only run on computers that have the Microsoft .NET
Framework installed. This is a collection of software that you or anyone else can download
and install at no charge from Microsoft's Web site. Several versions of the Framework are
available but two in particular are important here.

• Microsoft .NET Framework SDK

contains all the software you need to develop and run .NET programs, except for the
Visual Studio .NET development environment. The Framework SDK requires one of
these operating systems or later.
o Microsoft Windows 2000
o Microsoft Windows XP

• Microsoft .NET Framework Redistributable

contains only the software your friends, your coworkers, or even your enemies need
to run .NET software that already exists. The Framework Redistributable runs on
these operating systems or later.

o Microsoft Windows 98
o Microsoft Windows NT 4.0 (SP 6a required)
o Microsoft Windows Millennium Edition (Windows Me)
o Microsoft Windows 2000 (SP2 Recommended)
o Microsoft Windows XP

Installing the .NET Framework SDK on your own computer is no big deal; if it isn't installed
already, the Visual Basic .NET setup program will install it from the product CD.

If your friends, your coworkers, or even your enemies want to run your Visual Basic .NET
programs on their computers, they won't need to install the development software, but
they'll need to download and install the .NET Framework Redistributable. Have them
browse http://www.microsoft.com/downloads/ and then, under Search For A Download,
select .NET Framework Redistributable.

Of course, if there are any .NET Framework service packs available, you, your friends, and
those other people should download and install them.

Preparing for .NET Web Applications

Chapter 12 of this book, "Programming Web Forms," explains how to write Visual Basic
.NET programs that interact with the user through a Web browser rather than through the
Windows desktop. This has the advantage that people using your program don't need to
install your program files, don't need to install the .NET Framework, and in fact don't need
to install anything except the browser itself. You, however, will need a Web server on your
PC so you can develop and test these Web-based programs. This rules out Windows XP
Home Edition because no Web server is available for it.

The bottom line: If you plan to skip Chapter 12, then Windows XP Home Edition will do.
Otherwise, you'll need Windows 2000 or Windows XP Professional.
If you do want to try the Web exercises, you'll save steps by installing the Web server
before you install Visual Basic .NET. Here's the procedure for Windows XP Professional (if
you're using Windows 2000 the steps might vary slightly):

1. Open Control Panel.


2. Double-click Add Or Remove Programs.
3. Double-click Add/Remove Windows Components.
4. When the Windows Components Wizard dialog box appears, locate the list box titled
Components and make sure the Internet Information Services (IIS) check box is
selected.
5. Click Next and accept the defaults on any further dialog boxes.

To control or configure the Web server, choose Start, All Programs, Administrative Tools,
Internet Information Services.

If the Start Program menu doesn't display an Administrative Tools option, either run
Administrative Tools from the Control Panel or right-click Start, choose Properties, and
then:

• On Windows XP with the default Start menu in effect, choose Customize, then the
Advanced tab, and then at the bottom of the Start Menu Items list, under System
Administrative Tools, select Display On The All Programs Menu.
• On Windows XP with the classic Start menu in effect, choose Customize and then, at
the top of the Advanced Start Menu Options list, select Display Administrative Tools.
• On Windows 2000, right-click the taskbar, choose Properties, click the Advanced tab
and then, at the top of the Start Menu Settings list, select Display Administrative
Tools.

Sizing Your Computer

Microsoft recommends that Visual Studio .NET developers have at least a 450-Mhz
Pentium-II class processor and the following amounts of RAM:

• Windows XP Professional, 160 MB


• Windows 2000 Professional, 96 MB
• Windows 2000 Server, 192 MB

For installing any Microsoft Visual Studio product with Standard in its name, you should
have 2.5 GB of disk available, 500 MB of which must be on the system drive. Professional
and Enterprise versions of Visual Studio require 3.5 GB of disk space, again with 500 MB
on the system drive.
Microsoft also recommends at least a Super VGA (800 x 600) or higher video system that
can display 256 colors. In practice, even a 1024 x 768 system is likely to feel cramped. Use
the biggest monitor and best display card you can get.

Obtaining Visual Basic .NET


Microsoft distributes the Visual Basic .NET language and compiler without charge. You can
obtain it by installing the .NET Framework SDK as the section "Preparing for .NET Windows
Applications" earlier in this chapter described.

Note

If a copy of the Microsoft Web server—Internet Information Services—is present, installing


the .NET Framework Software Development Kit (SDK) will also install Microsoft Active
Server Pages (ASP) .NET. At that point, you could use Notepad, another text editor, or
even Microsoft FrontPage 2002 to create ASP.NET pages.

What's missing from the .NET Framework SDK is an integrated development environment
(IDE). An IDE is a cohesive set of development tools unified into a single graphical
application; that is, into a single Windows application. Creating, testing, and running
programs is much easier with an IDE than with just a text editor, and so this book assumes
you want an IDE.

Tip

There is no need to download and install the .NET Framework SDK if you plan to install any
Visual Basic .NET or Visual Studio .NET retail products. The product CD contains and
installs the SDK.

The predominant IDE for Visual Basic .NET is Visual Studio .NET. If you buy a retail
package with Visual Basic .NET in its name, you get a copy of Visual Studio that works with
Visual Basic only. If you buy a retail product sold as Visual Studio, it works not only with
Visual Basic .NET but also with Microsoft Visual C++ .NET, Microsoft Visual C# .NET,
Microsoft Jscript .NET, and additional languages.

This book assumes you've purchased Visual Basic .NET Standard Edition because that's
the cheapest way to get the Visual Studio IDE and the Visual Basic language. However, if
you've already purchased a more advanced version of Visual Basic .NET or Visual Studio
.NET, there's no need to uninstall it. You'll simply have more capability than you will with
Visual Basic .NET Standard Edition, and all the examples will still work.
Installing Visual Basic .NET
Installing Visual Basic .NET Standard Edition isn't much different from installing any other
Windows application. Here are the essential steps. Expect minor differences if you're
installing a different Visual Basic .NET or Visual Studio .NET product.

1. Insert Disc 1 and wait for the Setup window shown in Figure 2-1 to appear.

Note

In some cases, the installer might ask your permission to update software that the
rest of the setup process requires. Permit this until the window shown in Figure 2-1
appears.

Figure 2-1. This menu presents the main options for installing Visual Basic .NET.

2. When you initially install Visual Basic .NET, all the options but one in Figure 2-1 will
probably be unavailable. The one available option will be number 1, Windows
Component Update. This option installs any service packs and fixes that Visual
Basic .NET requires, as well as the .NET Framework SDK. Select this option and
follow the instructions as they appear.
A typical result from running the Windows Component Update would be installation
of the following components:

o Microsoft FrontPage 2000 Web Extensions Client


o Setup Runtime Files
o Microsoft .NET Framework

However, the exact components your system requires might vary.

3. When Windows Component Update finishes, option 2 in Figure 2-1 should be


available. Select this option.
4. When the Options Page dialog box shown in Figure 2-2 appears, select the options
to install and the disk location where you want them to reside. In most cases, you
should install all the items and place them in the default locations.

Figure 2-2. When this window appears, you can choose which Visual Studio options to
install and see how much disk space they'll take.

5. Click the Install Now! link shown in Figure 2-2 and supply any additional CDs as
required.
6. When you see a window titled Setup Is Complete, click Done.
7. When the Setup dialog box from Figure 2-1 reappears, option 3, Service Releases,
will be available. Select this option to compare the software on your system to the
most recent versions available on Microsoft's Web site. If this option recommends
downloading and installing new versions of anything, you should almost certainly do
so.
8. When the Service Releases option completes, click Exit to close the Setup dialog
box.

Easing into Visual Basic .NET


To get going with Visual Basic .NET, you must first start Visual Studio .NET. This is true
even if you installed Visual Basic .NET Standard Edition or some other retail package with
Visual Basic in its name. So, from the Start menu, choose:

• Programs (or, on Windows XP, All Programs).


• Microsoft Visual Studio .NET (the program group).
• Microsoft Visual Studio .NET (the program item).

The first time Visual Studio .NET starts it always displays the Start page, shown in Figure 2-
3. The titles along the left edge are menu choices and Visual Studio .NET helps you out by
selecting the last one, titled My Profile. This option affects the way Visual Studio .NET
configures itself every time it starts. The four drop-down lists above the line work together.

Figure 2-3. This panel appears the first time you start Visual Studio.

• The Profile drop-down list selects a combination of choices in the next three drop-
down lists. For example, if you choose the Visual Basic Developer profile, Visual
Studio sets the keyboard scheme to that of Visual Basic 6, the Windows Layout to
that of Visual Basic 6, and the Help Filter to Visual Basic. However, for now, select a
profile of (Custom).
• The Keyboard Scheme drop-down list configures the keystrokes that correspond to
menu options, toolbar buttons, and so forth. In past versions of Microsoft
development tools, these keystrokes differed from one language to the next. This
created endless confusion. Visual Studio .NET therefore uses the same keystrokes
for all languages, but by default, it uses its own set.

If you were a hard-core developer using one of those earlier products, you'd probably
have its keystroke conventions wired into your brain and you'd probably want to keep
using them. If you liked the Visual Basic 6 keystrokes, for example, you could
choose the Visual Basic 6 keyboard scheme and feel right at home. As a new
developer, however, there's no point in learning keystrokes from obsolete products.
Therefore, choose Default Settings in this list box.

Note

All the keystrokes in this book are from the default set.

• The Window Layout drop-down list controls which child windows Visual Studio
displays when it starts up. Now, Visual Studio uses a lot of child windows, and
unless you have an enormous monitor (and excellent long-distance vision) you'll
probably open and close these windows frequently as you work. In fact, after a while,
you probably won't care which windows are open on startup. For now, choose Visual
Studio Default.
• The Help Filter drop-down list affects the list of topics that appears when you search
Visual Studio Help. If you choose No Filter, for example, then searching the Help for
some keyword would return articles of all types. If you choose a Help Filter of Visual
Basic, the search would return only articles that are applicable to Visual Basic.

You can easily change this setting whenever you search for Help; as a result, its
initial value isn't terribly significant. For now, choose Visual Basic and then move on.

• The Internal Help and External Help choices affect the way Help windows appear. If
you choose Internal Help, then help windows appear as child windows inside Visual
Studio. If you choose External Help, then help windows appear in external windows.
Either choice is fine.
• The At Startup drop-down list configures what Visual Studio displays after the splash
screen and the main Visual Studio window. The options are the following:
o Show Start Page displays—you guessed it—the Start page! This is the page
that appeared in Figure 2-3 and that, most likely, currently appears on your
computer screen. The only difference is that Visual Studio selects the Get
Started pane rather than My Profile. The Get Started pane has options for
opening any project you worked on recently and for starting a new project.

Lingo

For now, think of a Visual Basic project as one Visual Basic program.

o Load Last Loaded Solution tells Visual Studio to load whatever solution was
open when you last closed Visual Studio. In effect, this option tells Visual
Studio to pick up where you left off. This is great if you work on one solution at
a time, but a nuisance if you switch from one solution to another. (In the latter
case, the most recent solution is frequently the wrong one.)

Lingo

A solution is a group of related projects (programs) that you work on


simultaneously. Visual Studio always loads a solution, even if it contains only
one project.

o Show Open Project Dialog Box displays an Open Project dialog box for
finding and opening any project in your file system. This is essentially the
same dialog box you'd use for opening a Microsoft Word or Microsoft Excel
document except that in this case, it looks for file types that Visual Studio
recognizes: projects, solutions, and so forth.
o Show New Project Dialog Box displays the dialog box for starting a new
project. If you start a lot of projects and finish them at one sitting, this is the
option for you. (Most projects aren't so simple and most programmers aren't
so fast, but if this works for you, go for it.)
o Show Empty Environment tells Visual Studio to display nothing but the main
window when it starts up. If you choose this option, then you'd typically use
options on the File menu to open the project you want.
The Show Start Page option is probably the best choice for beginners because it
helps you remember the last few projects you worked on and provides one-click
access to the screen for starting a new project. Feel free, however, to choose any
startup option you like. To display the Start page at any time, choose Show Start
Page from the Help menu.

Tip

You can also change the At Startup option by choosing Options from the Tool menu. When
the Options dialog box appears, open the Environment folder and then choose General.
The At Startup option is in the top right corner.

Try This!
If there's something about the Visual Studio environment that interferes with your
normal way of working, you're in luck; just choose Options from the Tools menu.
This displays the dialog box shown just below, which has options to change
almost any setting that annoys you.

To change the At Startup option, for example, open the Environment folder and
then choose General. The At Startup option is in the top right corner. To locate
and modify other settings, open the applicable category by clicking it, then click
the most likely subcategory.

Here are the high level option categories and their descriptions. If you need help
understanding the options on a particular panel, just click the Help button.
• Environment

sets default options for the integrated development environment (IDE).

• Text Editor

changes the default settings for the Visual Studio text editor. These defaults
also affect other editors based on the Text Editor, such as the Source view
in HTML Designer.

• Database Tools

changes the default settings for database projects.

• Debugging

sets default options for interactively monitoring and debug programs as


they run.

• HTML Designer

controls options that pertain to any HTML, Active Server, and Web Form
pages you open in the HTML Designer.

• Projects

sets options for using Visual Studio to develop Web applications.

• Windows Form Designer

changes the default grid settings for all visual designers within Visual
Studio.

• XML Designer

controls the default view when you open XML schemas and ADO.NET
datasets.
Other documents randomly have
different content
VI. THE ARMENIANS
When I was in Constantinople I felt the restless
tossings of long enthralled nationalities awaking to the
new destinies that might be theirs—Armenians
thirsting for their lost country and dispersed people;
Bulgarians panting and striving for freedom in a
Greater Bulgaria; Egyptians claiming independence;
Jews praying for a return to the land of David and
Solomon; Greeks dreaming strange dreams of a
greater and united Greece, yes, even of an eastern
empire restored to them, with Constantinople as its
centre. I saw the Turk, still defiant but apprehensive,
dimly conscious that the end is near at hand,
lamenting the sins of his people—such sins as that the
women do not wholly veil their faces, that the men do
not slay the infidels. I discerned the subtle plotting of
diplomacy to guard or gain the Queen City, and so the
empire of the East. Everything seemed then, as now,
uncertain. It might be peace, it might be war; but all
were sure that the old was breaking up, whether to
make way for inrushing floods of destruction, or for
better days and nobler nations, none could tell. Then I
went to the most sacred and vital spot of Stamboul,
not to St. Sophia, which, with all the lights and prayers
of Ramazan, testified only to the degradation and
defeat of the purer by a coarser faith, which had
become God’s scourge. I went to the Bible House, and
there first, while all was shaking about, I felt that I
stood upon a rock, the very Rock of Ages. The old city
had fallen because it was built upon a shut Bible; this
city was about to fall because it was built upon the
Koran. But here on the open Bible was being reared a
city which hath a foundation whose builder and maker
is God.

—Edward A. Lawrence in
“Modern Missions in the East.”

O
f all the races and sects of the Ottoman empire, none except
the Turks are so closely identified with the country, its progress
and present conditions, as the Armenians. They have been
preeminently the means and occasion for prosecuting missionary
work there, and the Armenian question has been discussed in the
parliaments of all Europe and even now is far from solution.
The Armenians constitute one of the two distinct Christian
peoples in the empire, the other being the Greeks. They stand with
the Greeks, a keen rival for the honors of antiquity, while from the
Christian standpoint they hold a position entirely unique. Their
antiquity, racial strength, intellectual alertness, large numbers, and
importance in that empire all demand a more extended
consideration.
There are two distinct sources from which account of them
comes,—one, their own historians, and the other, contemporary
historians. According to the former, they are the direct descendants
from Noah through Japheth, who was the father of Gomer, the
father of Togarmah, who begat Haig, the father of the Armenian
race. It is a fact to be noted here that they always refer to
themselves not as Armenians but as Haiks, and to their country as
Haiasdan. They find no little difficulty in pronouncing the word
“Armenia.” The name “Armenians” was applied to the race by outside
nations because of the exploits of one Aram, the king of Haiasdan,
the seventh removed from Haik, who made many conquests and
impressed the power of his arms upon the weaker people about him.
To these people the Haiks were the followers of Aram and so were
called Armenians. The Armenians claim that their present language,
except for the changes that have crept in through the centuries, was
spoken in the ark. Their traditions blend in the third and fourth
centuries before Christ with many facts of Assyrian, Median, and
Greek history, so it is impossible to differentiate precisely where
legend ends and history begins.
There is no doubt that during the Assyrian and Median period
there was in Armenia, which included the mountains of Ararat, and
the upper Araxes, Euphrates and Tigris rivers, centering perhaps in
the region of Lake Van, a well-organized and powerful monarchy.
The ancient Assyrian records show that this people had to be
reckoned with in all plans for campaigns in the Ararat country, and
not infrequently the invaders were compelled to retire in apparent
haste. Well-preserved inscriptions are found upon the cliffs at Van
and in the same language across the country six hundred miles or
more to the east, which show the presence there (700 b. c.) of a
powerful and warlike people. Whether these were the progenitors of
the present Armenian race or whether they were conquered by some
stronger invading force, which completely dominated the country, is
not as yet clear.
The last of the Haig dynasty, Vahe, formed an alliance with
Darius III against the Macedonians. He was defeated by the forces
under Alexander and was slain. The people were without a leader for
one hundred and thirty years, and were trampled upon and
plundered by invading armies from every side. About 190 b. c. two
Armenian nobles arose who divided the kingdom and ruled over it.
This divided kingdom was again united under Tigranes (Dickran II)
in 89 b. c. In 67 b. c. the Armenians became an ally of Rome, and in
30 b. c. were made tributary. For two and a half centuries thereafter
the entire country was again in turmoil and political disorder. From
that time to the present the Armenians have never represented a
political power that needed to be reckoned with. Their people were
scattered with no uniting force, without a commanding leader or a
distinctive country.
A little Armenian kingdom in Cilicia in the Taurus Mountains
maintained an existence until 1375 a. d. Since that time Armenians
have had no political existence whatever. They have been, and are
still, a people without a country, a nation without a government.
As soon as the Mohammedan invasion took place they had no
alternative but to yield to their conquerors or die. It was but natural
that they should scatter from the old ancestral haunts to all points of
the compass, in search of more liberty and a better opportunity to
secure a living. They have gone into every city, if not into nearly
every village of size in the empire. Before the massacre of 1895-96
there were nearly a quarter of a million Armenians in Constantinople
alone. Their energy and enterprise and industry give them
prominence in trade, in the professions, and in the cultivation of the
soil. They have gone far beyond the borders of Turkey, and are
found to-day in nearly every country in the world. Many hold high
and honorable positions in foreign lands.
Armenians exist in larger numbers still in their old haunts about
Lake Van, where they constitute perhaps a majority of the
population. In all the cities of Eastern Turkey, extending from the
Black Sea south into northern Mesopotamia, westward to the
Euphrates river, and beyond, they hold a prominent place, although
they are upon the whole a minority. The rest of the population are
mostly Turks, the ruling body, and the Koords. These races,
especially the Turks and Armenians, live in the same towns, but
never intermarry. The Koords live more by themselves in the
mountains. As we pass on into Asia Minor, the Armenians decrease
while the Greeks increase in numbers and in the importance of the
positions they command.
The Armenians are also numerous in northern Syria, especially in
the region near their last Cilician kingdom. Adana, Tarsus, Marash,
Aintab, Hadjin, Oorfa and many other cities in that region have a
large Armenian population. Their language is Turanian, constructed
upon the Greek model, and is especially rich in its power of
expressing Christian truths and sentiments. The most of the
Armenians speak this tongue, but some in the mountains of
Koordistan speak only Koordish, while the Armenians in northern
Syria use the Turkish language. Turkish is spoken by nearly all
Armenians, as well as by all the races north of Syria.
Religiously, the history of the Armenians is full of interest. Their
histories claim that at the time of Christ their king Abgar, called by
Tacitus the king of the Arabs, resided at Urfa in northern
Mesopotamia. He is reported to have had some communication with
Christ, who, at his death, through the apostle Thomas, sent
Thaddeus to preach to the Armenians. The king and his court were
baptized. His successor apostatized from the faith, and so
Christianity was lost to the race until the fourth century. At the
beginning of this century St. Gregory the Illuminator preached at the
court of Armenia with such effect that from that period to this
Christianity has been the national religion. The Church has held the
race together. It is known as the Gregorian Church, after St.
Gregory, while the people themselves always refer to their church as
Loosavorchagan, derived from Loosavorich, meaning “The
Illuminator.” As this is the national Church, all Armenian children are
baptized in infancy and become members.
AN ARMENIAN ECCLESIASTIC
A KOORDISH CHIEF
OF SOUTHERN KORDISTAN
At first the Gregorian Church took part in the ecumenical
conferences, but for some reason they had no representatives in the
council which met at Chalcedon in 451 a. d. In a synod of Armenian
bishops in 491 the decisions of the council of Chalcedon were
rejected, and at a later synod they declared openly for the
Monophysite doctrine. This led to their complete separation from the
Greek Church.
Their church government is Episcopal, with the same form of
patriarchal control which dominates the Greek Church in Turkey. The
bishop of the main body of the Armenians resides at Etchmiadzin,
their holy city, now in Russia, not far from the Turkish borders. There
is also a bishop on the island of Octamar in the lake of Van, and
another at Cis in Cilicia, each with a small following. The bishops
have authority over the spiritual affairs of the Church, like the
ordaining of priests and vartabeds, while the two patriarchs, one at
Jerusalem and one at Constantinople, control its temporal affairs. As
these patriarchs, and especially the one at Constantinople, are in a
measure the appointees of the sultan, and as he represents his
people in all their government matters, the office is largely political
and secular. The importance as well as the delicacy of the position is
greatly increased during the times of political unrest.
At its beginning, the Church was as pure in doctrine and practise
as was the Greek Church at Constantinople. It was an important
branch of the Church of Christ on earth. The location of the
unprotected Armenians, in a country swept by invasion and
persecutors of every kind, made the position of the Church a most
trying one. As illiteracy increased, the spoken language of the people
underwent marked changes. The Church possessed most sacredly
guarded manuscript copies of the Scriptures and beautiful liturgies,
all in the then spoken language of the people. These were read at all
church services and sermons were preached by the officiating clergy.
As the spoken language changed during the last ten centuries, under
the blasting influence of Mohammedan rule, the sacred books of the
Church ceased to speak to the people. The priests read the words of
the ritual, but neither they nor the people understood it. The church
was too holy a place in which to make use of the vulgar vernacular,
so the sermon was discontinued because there was no one to
preach in the classic tongue of the race.
Under these conditions the Christianity of the Gregorian Church
became, for the most part, a religion of form, from which the spirit
had departed. Thus bereft of the true power of Christianity and
subject to the temptations and persecutions of the Moslems among
whom they dwelt, it is not strange that the Christianity of the
Gregorian Church lost its vital power.
VII. MOSLEM PEOPLES
What was said above concerning Islam as the
hereditary faith of the Ottoman Turk does not hold true
of the other Moslem races of Turkey. Koords,
Circassians, Albanians—nearly half as many, all
together, as the Turks—are, at best, but half
Mohammedan. To a large extent the profession of
Islam by Koords and Circassians is purely outward and
formal, while their esoteric faith is a mixture of
Mohammedanism, Christianity and heathenism. In
grouping and generalization we cannot go farther than
the statement just made. Take the Koords alone. There
is almost infinite variety in their religious beliefs and
superstitions. It is well known that there are whole
villages among them ready to declare themselves
Christians, could they be assured of protection in so
doing. The Moslem Albanians—somewhat more than
half the race—are more bigoted and violent
Mohammedans than the Turks, just as the Janissaries,
likewise of Christian origin, who were compelled from
childhood to embrace Islam, out-Heroded Herod in the
fanaticism of their anti-Christian zeal.
With the exception of the Albanians, Islam has, in
all the centuries of the reign of the Ottoman Power
over these lands, made very slight gains from the
Christian races. The number of Greek, Armenian,
Bulgarian, Roumanian, Servian, Bosnian, or
Montenegrin Mohammedans is insignificant. Of these
seven races, for hundreds of years under Moslem
sway, the number to-day free from Ottoman control is
nearly equal to the entire population, Moslem and
Christian, now directly under Turkish domination.

—From “The Mohammedan World of To-day.”

THE KOORDS

B
esides the Turks and Armenians, no race in Turkey has
commanded more attention during the past two decades than
the Koords. They have attracted the notice of the world by their
large part in the Armenian massacres in 1895-96 as well as by their
relations to the sultan himself through the organization and arming
of the Hamidich cavalry within the last quarter of a century. They
were almost unknown and unheard-of except locally until they came
into prominence at the time of the siege of Erzerum by the Russians
in 1876, when the Koords were used by the Turks in defense. They
rendered little real service, however.
Whatever else may be said, this race has now to be reckoned
with in all plans for propagating Christianity in any form in Eastern
Turkey and western Persia, as well as in all questions of order in that
region. Sometimes they are in open conflict with the Turks, and
troops are mobilized and sent against them in their mountain
fastnesses. Again they are provided with arms by the government
and sent out to subdue and suppress revolutionary bands of
Armenians who are more ambitious than discreet in their endeavors
to obtain liberty.
Little is known of the origin and history of this wild and most
interesting people. They probably are the direct descendants of the
Karduchi, who occupied the same plateaus and commanded the
same mountain passes that the Koords now hold. It is probable that
they are not a race by themselves, but a collection of tribes with
little among them all that is common except their hardihood,
roughness, and tendency to plunder. One chief, whom the writer
knew, declared that his ancestors came to the upper waters of the
Tigris from Mesopotamia some eight centuries ago, and, after
conquering the region, ruled it as feudal lords. That form of
government is in existence among them even at the present time.
Undoubtedly the word Koord, Kurd, Gutu, Gardu, or Karu, has been
promiscuously applied to any mountain race, clan, or tribe occupying
the upper waters of the great rivers in that part of the empire, if
they were not already claimed by another race.
There are some marked distinctions between the peoples called
Koords. Some are nomadic and pastoral, taking their flocks into the
north of Armenia as the summer advances, and returning to the
warmer regions of the south as it recedes. These live almost entirely
in black tents, and, while they steal, are not generally robbers.
Others settle in villages and the men devote their time usually to
robbing traders and caravans passing through their country, and
levying blackmail upon the Armenians who dwell upon their borders.
It is this class who cause both the Turkish government and the
Armenians the most trouble. A chief, whom the writer knew
personally, and at whose castle he has often passed the night,
boasted that he owned nearly four hundred villages with the
adjacent land, and could throw, within two days’ notice, two
thousand armed horsemen into a fight anywhere within the bounds
of his territory. He said that he had over three hundred armed men
out upon the road most of the time. His castle had dungeons, and
was, to all intents and purposes, a fort.
These various Koordish leaders not only have little in common,
but they are frequently in open conflict one with another. Could
these people unite under a bold leader and form an alliance with the
Arabs of the south, nothing in Turkey could stand against them.
Many renowned leaders from among the Koords have appeared from
time to time. Saladin, a noted ameer at the time of the crusades,
was a Koord.
They occupy the mountainous regions throughout Eastern
Turkey, reaching far down the Tigris to Mosul and into Mesopotamia,
extending into Persia upon the east and coming west as far even as
Anatolia. The mass of the Koords dwell within this area, but not a
few are found outside. An estimate given of their numbers places it
as high as 3,000,000.
Their languages are unclassified. There are two of them, neither
of which ever was put into writing except within the last generation,
so that the spoken tongues of those professing to speak the same
language greatly differ in different parts of the country. Their speech
is rough, like the life they live, and resembles in no small degree the
barren cliffs amid which they dwell.
Some years ago Sultan Hamid II conceived the idea of subduing
the Koords in the eastern part of his dominions by calling the chiefs
to Constantinople and making them each commander of a body of
their own people, giving this troop his own name as a special honor.
The chiefs were to provide the men and the horses and the sultan
furnished the equipment. The proposition was most acceptable to
the Koordish nobles, for it provided them with modern equipments
of warfare and at the same time stamped their acts, even of
depredation, with official authority. Under the new dispensation,
whoever offered resistance to a Koord armed with a government
rifle, by that very act put himself into open rebellion against the
government. These conditions prevail at the present time in the
Erzerum, Bitlis, Diarbekr and Van vilayets along the Russian frontier.
Much of the trouble of the last fifteen years in these regions is due
to this fact. Were it not that the Koords are urged by the
government to take aggressive measures against the resident
Christian population, conditions there would be better than they are
at the present time.
It is often stated that all Koords are Mohammedans. The Turks
take this ground, as they do regarding the Albanians of Macedonia.
The fact is that few of the Koords are good Moslems. They do not
hesitate to put out of the way a Turkish tax-collector who makes
himself obnoxious. The fact that he is a brother Moslem interposes
no obstacle. Many of them observe few of the rites and customs of
Islam, and one tribe, at least, living along the upper waters of the
Euphrates openly declares that it is not Mohammedan. The writer, in
conversation with a leading man of that tribe, said, “You are a
Mohammedan.” With great indignation he spat into the air, and,
beating upon his breast, he said, “I am a Koord; Moslems are dogs.”
They have certain religious rites which greatly resemble some of the
Christian customs, as, for instance, they have a service in which
bread dipped in wine is put into the mouths of the kneeling
participants by their religious leader. These people often tell the
Armenian Christians that their sympathy is with them rather than
with the Turks.
Owing to the claim of the Turks that all Koords are
Mohammedans, missionaries have not been able to inaugurate
special work among them. Throughout the country called Armenia
and where the Armenians are the most numerous, there also the
Koords are found in the largest numbers. Frequently they reside in
the same city, side by side, but more often the Armenians dwell in
the plains, where they are the cultivators of the soil, while the
Koords live higher up the mountains. A study of the regeneration of
the Turkish empire cannot be complete without giving large
consideration to this ancient, wild and violent people.

THE TURKS
In Turkey the word “Turk” is used only to designate a
Mohammedan. A Greek who had accepted Islam would at once be
called a “Turk.” It would be said of him that “he had Turkofied
himself.” In its ordinary use, therefore, in Turkey it signifies a
religious belief and that alone. The same may be said of the other
names for nationality, such as Armenian, Greek, Jacobite, Yezidi,
Koord, etc. Instead of using the word “Mohammedan” at this point
we will consider this part of our subject under the title “The Turks,”
thus keeping the national and religious parallel intact.
The Turks of Turkey comprise every race that has ever lived
within its territory and has accepted Islam. As the people of the
different races embrace Islam, they come at once into the
Mohammedan body and are in a large measure unified with it by the
common customs imposed upon them through the government and
by their religion. These assimilated races marry and intermarry so
that to-day, outside of Arabia, where the race has been kept more
free from mixture, it is difficult to find among the Turks a clear racial
type.
The original Turkish people were invaders, coming into the
country from the north and east for plunder and conquest. As soon
as these conquering hordes accepted Islam, every victory over a foe
meant new women for the harem and added men who chose Islam
to tribute or death. When the country had been overrun and Turkish
rule was established, there was exhibited the spectacle of a
Mohammedan body of officials from every race of the East, scattered
over all parts of the empire, except possibly some sections of
Koordistan and Arabia, administering a government over the other
races dwelling among them. The Turks alone could hold office, serve
in the army, collect the taxes, and control affairs. In Arabia the rulers
or Turks (not so called there, however) comprised the main part of
the population and so had things their own way. In all other sections
of the country, other races, and not infrequently races of strength
and energy who had occupied that same territory for generations
before Mohammedanism arose, looked upon the Turk as an intruder
and were not slow to make him aware of the fact. These were, for
the most part, disorganized, and, by Turkish law, disarmed, so that
little could be done to change local conditions.
The Druses of Syria, the Koords in Eastern Turkey, and the
Albanians of Macedonia were reckoned as Mohammedans by their
rulers. As these people had few religious convictions of any kind, and
as the Mohammedan yoke placed upon them did not seem heavy,
they fell in with the idea in so far as it seemed to conserve their
interests to do so. Even at the present time, it is not clear how
sincerely these races are Mohammedan. It is thought by many who
have been among them that their Mohammedanism is largely in
name. During recent years, undoubtedly influences have been
brought upon the Koords which bound them more closely to the
sultan, although this is not true of all classes of Koords.
Years of Turkish rule, by which the non-Moslem subject is looked
down upon as a “Raya” who has no rights that a Mohammedan is
bound or expected to respect, has made the Turk selfish and cruel,
while it has hardened the Rayas, and made them hate the
government. It has come to be generally understood that the
government exists only for the Turks, to serve whom the Rayas are
permitted to live. Through several centuries of Turkish rule, when
the Raya subjects of the Turks were in grossest ignorance and widely
scattered in the country, they came to accept in stolid silence the
situation as divinely ordained. Something of the fatalism of their
masters seemed to settle down upon even the Christian subjects
and, with little complaint, almost human slavery was accepted.
If the immediate possessions of Turkey include a population of
about 24,000,000, probably 6,000,000 of these are nominal
Christians, and perhaps 1,000,000 are neither Christians nor
Mohammedans.
It should be said that among the Turks are found men of great
strength of intellect, and not a few of high character. Every one who
has been in the country speaks of men of this class whom he has
met. All would probably agree with the statement that the Turk as a
whole is far better than his government.
It should also be stated that in recent years the Turks themselves
have been more boldly open in expressing their intense
dissatisfaction with the methods of government administration,
especially in the eastern part of the country. The New Turk Party, so
called, has no one knows how many followers, but undoubtedly it
represents the modern spirit of unrest and progress.

OTHER RACES
We need not speak at length of the Circassians, who in some
respects are the most interesting race in Asiatic Turkey. These are
Mohammedans who came into Turkey in large numbers after the
Russian conquest of the Caucasus. Their business is primarily
robbery. They are a race which must be reckoned with in the
northern half of Asia Minor. We must pass over the Turkmen, or
Turkomans, who can be traced back at least eight centuries. These
are also Mohammedans and nomads in their habits. They are found
in considerable numbers, scattered mainly over the southern half of
Asia Minor. There are also the Albanians in the western part of
European Turkey, able to substantiate their claim of being one of the
purest and oldest races in Europe. These number perhaps two
million souls, and are more united as a race than either the
Circassians or the Turkomen. All three of these peoples are
nominally Mohammedans, and from them have come some of the
ablest and best of the Turkish officials.
The Bulgarians have a government of their own, practically
independent of Turkey. Many of these, however, dwell in Macedonia,
together with Turks, Albanians, and Greeks, and so constitute an
important part of the Macedonian question. These are Christian and
were originally a part of the Greek Church, with headquarters at
Constantinople. They are a sturdy, vigorous, and intelligent race.
Space forbids the mention of other minor races like the Yezidis,
neither is there call for a description of the Arabs who dwell in
Arabia and northward.
It is sufficient to say that all these divergent, crude, and often
hostile races, each with a religion differing from that of all others,
together constitute the people of the Turkish empire. The
dominating class is the Turk, representing the Mohammedan faith,
but far from harmonious even among themselves, except as they are
practically united in a common hatred of the Christians and in a
common purpose to keep them from gaining supremacy in wealth,
number, intelligence, or influence.
Outside of the large coast cities there are but few people in
Turkey who are not native to the country. Turkey has offered little
attraction to people of other countries for colonization. Far more are
seeking to leave that country than are attempting to enter it. The
exactions of the government upon all who dwell within the empire,
the insecurity of the protection afforded to life and property, and the
risks which gather about trade and commerce are not calculated to
attract foreign capital or induce natives of other lands to immigrate
there.
VIII. TURKEY AND THE WEST
Only last year the Arabic paper, Es-Zahir, published
in Egypt, said: “Has the time not come yet when
uniting the suppressed wailings of India with our own
groans and sighs in Egypt, we should say to each
other, Come, let us be one, following the divine words,
‘Victory belongs to the united forces’? Certainly the
time has come when we, India and Egypt, should cut
and tear asunder the ties of the yoke imposed on us
by the English.” On the other hand, Mohammed
Husain, the editor of a paper at Lahore, wrote a
treatise on Jihad (1893), stating: “The present treatise
on the question of Jihad has been compiled for two
reasons. My first object is that the Mohammedans,
ignorant of the texts bearing on Jihad and the
conditions of Islam, may become acquainted with
them, and that they may not labor under the
misapprehension that it is their religious duty to wage
war against another people solely because that people
is opposed to Islam. Thus they, by ascertaining the
fixed conditions and texts, may be saved forever from
rebellion, and may not sacrifice their lives and property
fruitlessly nor unjustly shed the blood of others. My
second object is that non-Mohammedans and the
government under whose protection the
Mohammedans live, may not suspect Mohammedans
of thinking that it is lawful for us to fight against non-
Mohammedans, or that it is our duty to interfere with
the life and property of others, or that we are bound to
convert others forcibly to Mohammedanism, or to
spread Islam by means of the sword.”
So the question of “religion and the sword” is still
an open one among Moslems. It must needs be so
long as they obey the Koran and tradition, for
Mohammed said, “He who dies and has not fought for
the religion of Islam, nor has even said in his heart,
‘Would to God I were a champion that could die in the
road of God,’ is even as a hypocrite.” And again, still
more forcibly, “The fire of hell shall not touch the legs
of him who is covered with the dust of battle in the
road of God.” In spite of cruelty, bloodshed, dissension
and deceit, the story of the Moslem conquest with the
sword of Jihad is full of heroism and inspiration.

—S. M. Zwemer, F. R. G. S. in “Islam.”

S
elim III, sultan of Turkey from 1789-1807, more formally and
openly displayed the spirit and purpose of reform than had any
of his predecessors. He had been carefully educated, and conceived
the bold design of becoming the regenerator of the empire. He
erected a printing-press at Scutari, welcomed intelligent foreigners,
employed Christian workmen, and, among many other things,
changed the system of taxation. He also called in European generals
to train his army, and sought advice from the European residents of
his capital. In the meantime, the invasion of Egypt by Napoleon had
stirred up the passions of the populace of Constantinople, and the
sultan with his unpopular reform measures tottered upon his throne.
Russians marched into the Danubian provinces, while a British fleet
passed the Dardanelles and anchored at the mouth of the Bosporus.
The Janissaries mutinied in 1807 and Selim’s rule ceased. These
internal imbroglios had attracted the attention of the world to
Constantinople and Egypt, if not to all Turkey.
After the brief reign of Mustipha IV, Mahmud II ascended the
throne in 1808. He possessed extraordinary energy and force, and
warmly espoused the reform measures of Selim. Resisting Russia’s
demand that all Greeks in Turkey should be placed under the
immediate protection of Russia, he was soon at war with that
country. Napoleon prevented the occupancy of Constantinople by the
Russians, but most of the Danube province was lost. A Hellenic
revolution was later fermented which broke into open conflict early
in the beginning of mission work in Turkey.
Turkey as a government and as a factor in the relations of Russia
to Europe was thus brought to the attention of the West. At the
same time there was a revival of interest in the Jews, both in Europe
and in the United States. There was a restudying of history and
prophecy with new interpretations, which led to the formation of
societies to circulate among them the New Testament and to preach
to them the gospel of Christ. Naturally, Palestine and Syria came first
of all to be recognized as a land that had peculiar claims upon
Christians. There was a wide-spread belief that the Jews were about
to return to their ancestral home, and that such return would be
limited only by the obstructions put in their way by the Ottoman
government. Levi Parsons, the first American missionary to Palestine,
said, in 1819, just before sailing, “Destroy the Ottoman empire and
nothing but a miracle will prevent the Jews’ immediate return from
the four winds of heaven.” It was natural that, in their judgment,
missionaries ought to be there to receive them when the Ottoman
empire, then apparently in its death struggle, tottered to its fall.
Moreover, the Turkish empire embraced the lands of the Bible.
There was in the minds and hearts of American Christians not a little
of the spirit of the crusaders of the middle ages. Why should the soil
trodden by the feet of the prophets and apostles, yes, even by the
Lord himself, remain a stranger to the voice of the preacher of
righteousness and untouched by the feet of the modern apostle?
The instructions given to the first missionaries to Turkey dwelt upon
this impressive and moving fact, as did the early letters of the
missionaries. Unlike the crusaders, these aimed at a purely spiritual
conquest, but it included the Christian subjection of all races and
peoples.
As a part of this same impulse may be placed the interest in the
historic Greek and Syrian Churches. Students of Church history were
profoundly moved as they learned of the decadence of vital
Christianity in these Churches, and they were thrilled with the desire
to inaugurate among them a revival that should restore them to their
former prominence and power. The purpose to reach Mohammedans
does not appear prominent in the earlier documents of this period,
although it is not by any means entirely wanting.
In view of these facts and also since Turkey was the most
accessible to America of any Asiatic country, it is not strange that in
1819, with unusual enthusiasm, two missionaries, Levi Parsons and
Pliny Fisk, were set apart for work in Turkey by the American Board
of Commissioners, with special reference to the Jews in Palestine.
As a strategic center in which to begin to prosecute missionary
work, few countries are more attractive than Turkey. It lies along the
southern border of Russia throughout its entire length, except as
separated by the Black Sea. Upon the east it borders upon Persia,
and constitutes almost the only approach to this country of the shah,
as well as to the Caucasus possessions of the czar. Arabia, Egypt,
and North Africa all border upon the same Mediterranean Sea, and
many important islands like Cyprus and Crete lie but little off its
coast.
Constantinople, the capital of the Ottoman empire, occupies the
most strategic position of any city in Europe and dominates both the
European and Asiatic sides of the Bosporus. To this center all the
great and historic cities of Turkey look for political direction, and to it
come sooner or later representatives of every tribe and race in the
empire. All traffic from the Black Sea to the outer world and even
from Persia and southern and eastern Russia must perforce pass
through Constantinople and the Dardanelles. It stands upon the
highway and at the crossroads of commerce and travel. As a base
for missionary operations, not only upon Turkey but upon adjacent
countries as well, it is unexcelled. Smyrna upon the Grecian Sea,
with immense populations behind it, by the strategic force of its
location, commanded the early attention of those sent out to explore
for location. Beirut in Syria attracted for the same reason the
attention of the missionaries to Palestine.
There is an advantage in carrying on missionary work among
sturdy races. When such are converted, they become a force in the
work of the Church, the conduct of Christian institutions, and the
propagation of the gospel. No country in the world could present
such an array of ancient, historic, and hardy races as Turkey. Race
survival there was under the law of the survival of the fittest. None
but the invincible remained. Some had proven themselves invincible
by arms, others had conquered by superior intelligence, strategy,
and cunning. Each race remained because, in some particular, it had
an advantage over its natural and persistent antagonists. The very
fact that these races had kept themselves apart, resisting gradual
absorption while repelling open attempts at conquest, and all for
twenty centuries or more, testifies to their sturdy worth.
Some of these, like the Greeks, Armenians, Jews, and Arabs, had
been masters of an ancient and proud civilization, in which learning
had high place and religion was supreme. There was no ground for
questioning native ability to grasp the principles of Christianity when
once these peoples were enlisted. A modern Church and a modern
civilization built upon such historic races, and propagated by such
men, could not fail to become an irresistible force in that needy land.
It is no wonder that the officers of the American Board of Missions
early concluded that the Ottoman empire was a strategic point in
which to plant modern Christianity and the institutions which it
fosters and propagates.
While the sultan represents one sect of Mohammedanism,
namely, the Sunni, and the Persians another, the Shiah, between
whom there has existed great and often bloody hostility, yet the
Persian Mohammedans make their pilgrimages to Mecca, pray
towards that holy of holies, and reverence the sacred relics in the
keeping of the sultan. However much the shah may bluster, he
listens when the sultan speaks. His country can find outlet in the
West only across Turkey, and much that comes from the outside
world comes through some part of the Turkish empire. As the
Nestorians and Armenians are found upon both sides of the line, and
constitute the chief non-Moslem populations of Persia, it was most
natural to connect the mission work of Persia directly with that in
Turkey. Such a connection holds to the present time. In many
respects Turkey was the key to Persia and is to-day.
At the beginning of mission operations, Russia was especially
open to the circulation of the Scriptures in the vernacular. It was
hoped and expected that soon the entire country would be
accessible for direct Christian and educational operations among the
millions of that empire. The whole Caucasus region can be easily
approached by no other route than the Black Sea. The Armenians
dwell in large numbers in that section of the country and are
constantly passing back and forth in trade and commerce.
Constantinople lies at the crossing of all roads from the Black Sea
regions and beyond to the outer world and the West.
The Balkan peninsula and Macedonia, lying to the north and
west, also center in the capital of the Ottoman empire. As the seat
of government for Macedonia and the province of Adrianople, all
political influence and movement are that way. For generations it
was the capital of the Balkan provinces and even yet it is the great
metropolis to which merchants, students, and workmen go for a
longer or a shorter period of residence abroad. There is no other
center so well calculated to be the base of operations upon all that
region.
The American Board was organized in 1810 and its first
missionaries were sent out in 1812. These went to the farther East,
to India and Ceylon. It was not the intention of the Board to confine
its foreign operations to these two countries. Christian leaders in
America were surveying the world for the purpose of finding other
countries in which to establish Christian missions. Explorations into
the western parts of our own country resulted in beginning work
among the Indians as early as 1816. It is not surprising that in their
survey of the wide world, its special needs and promising openings,
attention should have been early called to Turkey.
IX. A STRATEGIC MISSIONARY
CENTER
In Constantinople one does not fail to meet Greeks
and Armenians who are bright and entertaining and
obliging, or Mohammedans who are noble and
courteous, and thoughtful enough to make their
acquaintance an acquisition. But every study of the
people in mass is a revelation of arrested
development, absence of initiative, and general
uselessness by reason of narrow selfishness. The city,
and with it the millions to whom the city is model,
seems hostile to what is best in the world’s work. High-
sounding phrases of lofty principle are heard in the
city. Custom provides for this much of concession to
the sensibilities of others. But the centuries seem to
have frayed off the last semblance of meaning from
the words. To quote a remark of a sage official in India
which applies to the whole of Asia, “Whilst the mouth
is proclaiming its enlightenment and progress, the
body is waddling backward as fast as the nature of the
ground will permit.” The bane of Constantinople is not
solely poverty of resources; it is poverty of ideals.

—Henry Otis Dwight, LL. D.


in “Constantinople and its Problems.”

W
hile the political and commercial importance of Constantinople
is supreme, when considered in relation to the Powers of
Europe and the far East, this is insignificant in comparison with its
religious importance in relation to the Mohammedan world. So far as
we can learn, this fact did not receive large consideration at the time
missions in Turkey were begun. The truth is that it did not then hold
the commanding relations to the Mohammedans of other countries
that it holds to-day. The present reigning sultan, Hamid II, has done
more than any of his predecessors to secure for himself recognition
by all the faithful as the one supreme head, the caliph of Islam. He
has sent presents with messages of sympathy and encouragement
to Mohammedans in India, China, and Africa, and these have been
received as from the great living head of the Moslem faith. When our
government found itself in possession of a country in which a
Mohammedan ruler was enthroned, it found it convenient to carry on
negotiations for submission through the sultan of Constantinople.
There are probably 230,000,000 Mohammedans in Turkey, Europe,
Persia, Africa, India, China and other countries, who look upon the
sultan of Turkey as the representative on earth of their revered
prophet Mohammed. As such, he does not possess or assume
temporal authority, or even well-defined spiritual prerogatives, but
he does command an influence that has been secretly discussed in
many European cabinets, and which has been taken into
consideration in dealing with Moslem races and in administering
ultimata to the head of the Ottoman empire. The sultan clearly
represents a temporal and a religious power. The strength of the
temporal influence lies in his relations religiously, not only to his own
mediate and immediate subjects, but to all followers of the prophet
Mohammed, whatever language they speak and in whatever land
they dwell.
The official title of the sultan is padishah, father of all the
sovereigns of the earth. This is the name exclusively used by the
Turks in official communications. He is also called Imam-ul-
Musselmin, the supreme pontiff of all Mussulmans or
Mohammedans; Zilullah, the shadow of God; and Hunkiar, the slayer
of infidels. By these and other similar titles he is known as far as the
Mohammedan religion has gone. No one else claims such honors
and to him they are conceded. Destroy his religious power and he
would be the most impotent of monarchs, but with it he has defied
for three generations the efforts of the Powers of Europe to secure
some degree of justice and freedom for his oppressed subjects.
The sultan holds his religious power through two important facts.
The first is that the two sacred cities of Islam in Arabia are within his
empire and under his control—Mecca, the birthplace of the prophet,
and Medina, which contains his tomb. This sacred territory is
prohibited to infidels, but is the goal for tens of thousands of Moslem
pilgrims each year. There is no faithful follower of Mohammed who
does not dream of the time when he will be so blessed as to kiss the
black stone of the Kaaba, drink of the well of Zemzem, or have a
part in the prolonged ritual which shall entitle him during the rest of
his life to the honored name of Haji.

THE BOSPORUS, CONSTANTINOPLE


Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like