visual book

8
Introdu Usin Prof. Minist Revised by Prof. Salah Amin El Director, Technology Develo Ministry of Education uction to Programm ng Visual Basic.NET Prepared by .Ahmed Fahmy Amin Mahrous Professor of Computer, AAST ter's Consultant for Information Technology Translated Eng. Emad El-Din Els American University lewa opment ming T by sayed Ahmed y in Cairo

Upload: mohamedmostafasanad

Post on 13-Dec-2015

218 views

Category:

Documents


0 download

DESCRIPTION

This book is designed primarily to teach programmingfundamentals. The important point here is that many Visual Basic textsfocus on the “Cool Visual Basic gizmos” and, in doing so, fail to teachthe programming concepts that are common to all languages. That is whywe titled our book “Introduction to programming using Visual Basic DotNET”, not “Learning Microsoft Visual Basic Dot NET”. We think thisdistinction is important because languages come and go, but fundamentalconcepts underlying the programming process stay fairly constant.

TRANSCRIPT

Introduction

Using Visual Basic

Prof.Ahmed Fahmy Amin Mahrous

Minister's Consultant for Information Technology

Revised by

Prof. Salah Amin Elewa

Director, Technology Development

Ministry of Education

Introduction to Programming

Using Visual Basic.NET

Prepared by

Prof.Ahmed Fahmy Amin Mahrous

Professor of Computer, AAST

Minister's Consultant for Information Technology

Translated

Eng. Emad El-Din Elsa

American University in

Prof. Salah Amin Elewa

Director, Technology Development

to Programming

.NET

by

in Elsayed Ahmed

American University in Cairo

Acknowledgments

Most importantly, we are grateful to Prof. Yousry Saber Elgamal,

the Minister of Education, for giving us the opportunity to write this

book, for his support and understanding.

Many people have worked very hard to design and produce this

text. However, there are a number of people who deserve special

recognition. First we would like to thank Mrs. Suzan Abdel Fatah

Marzouk, the general director of Computer Education, and Mrs. Salma

Aly Ibrahim, the Computer expert, for their extremely helpful

suggestions on content and pedagogy as well as revision of the Arabic

version.

The Graphics department at the Ministry of Education also

deserves recognition and thanks for all their help. This includes Dr.

Fathia khairy and Eng. Manal Elgendy for their remarkable job that

turned the rough wording into a fine book.

Preface

This book is designed primarily to teach programming

fundamentals. The important point here is that many Visual Basic texts

focus on the “Cool Visual Basic gizmos” and, in doing so, fail to teach

the programming concepts that are common to all languages. That is why

we titled our book “Introduction to programming using Visual Basic Dot

NET”, not “Learning Microsoft Visual Basic Dot NET”. We think this

distinction is important because languages come and go, but fundamental

concepts underlying the programming process stay fairly constant.

If teaching programming fundamentals is our primary goal, then

why we have chosen Visual Basic Dot NET and not some other

language? The answer is simple: we feel that Visual Basic Dot NET is the

language that facilitates our main goal by being relatively easy to learn

without the overly complex syntactic and semantic rules found in some

other languages.

In fact, our book is consisting of two parts, one part for each term.

If you look at table of contents of this part, you will find that it consists of

6 Chapters:

• Chapter 1 gives you an idea about programming languages

and the differences between compilers and interpreters.

• Chapter 2 explains the Flowcharting. This chapter has many

solved examples.

• Chapter 3 explains the Pseudocode fundamentals. In this

chapter we wrote the pseucode for all examples of Chapter 2.

• Chapter 4 explains the principles of Object Oriented

Programming (OOP) in a very smooth way.

• Chapter 5 gives you a tour of Visual Basic .NET 2005

Integrated Development Environment (IDE). In addition, it

shows you how to Create your first Visual Basic project.

• Chapter 6 Lists the characteristics of several Visual Basic

.NET

Controls –the objects that appear on the user interface- and

the uses of each one. It includes many examples to show

you how to use the controls.

The course website, available at www.moe.org.eg contains a number of

files that give you the opportunity to see visually the steps taken to solve

any given example.

Table of Contents

CHAPTER ONE

CHAPTER TWO

An introduction to Programming

1.1 Information system

1.2 Computer Operations

1.2.1 Input Data (Reading Data)

1.2.2 Store data in memory

1.2.3 Perform arithmetic operation on data

1.2.4 Compare two values and select one of

two alternative actions

1.2.5 Repeat a group of actions any number of

times

1.2.6 Output the results of processing

1.3 Programs and Programming

1.3.1 Programming Languages

1.4 Questions

Problem Solving and Flowcharting

2.1 Introduction

2.2 Flowcharting

2.2.1 The Meaning of a Flowchart

2.2.2 Guidelines for Drawing a Flowchart

2.2.3 Advantages of Using Flowcharts

2.2.4 Limitations of Using Flowcharts

2.3 Some Examples of Flowcharting

2.4 Questions

1

1

3

3

4

4

4

5

5

6

6

9

10

10

14

14

15

17

18

18

34

CHAPTER THREE

Pseudocode

3.1 Introduction

36

36

3. 2 Components 37

3.3 Rules and Constraints 38

3.4 Program Logic Structures 39

3.4.1. Sequence 39

3.4.2. Selection 39

3.4.2. Iterations 41

3.5 Advantages and disadvantages of Pseudocode 43

3.6 Some Examples on Pseudocoding 44

3. 7 Questions 57

CHAPTER FOUR Object Oriented Programming (OOP) 59

4.1 Introduction 59

4.2 The Object Model 60

4.2.1 Objects 60

. 4. 2.2 Properties 61

4.2.3 Methods 62

4.2.4 Events 64

4.2.5 Classes 66

4.3 The Object Oriented Terminology 69

4.3.1 Encapsulation 69

4.3.2 Inheritance 71

4.4 Questions

72

CHAPTER FIVE

Introduction to Integrated Development

Environment (IDE)

5.1 Installing Visual Basic .NET 2005

5.2 The Visual Basic 2005 IDE

75

75

75

5.2.2 The New Project Dialog 77

5.2.3 The IDE main window 78

5.3 Creating your first Visual Basic (VB)

Project

81

5.4 Saving Your Application 85

5.5 Running your Windows Form 86

5.6 Questions 89

CHAPTER SIX Introduction to Controls 91

6.1 The Windows Form Control 91

6.2 The Button Control 92

6.2.1 Button's appearance and properties 92

6.2.2 Events 99

6.3 The Label Control 116

6.3.1 Label Control 's appearance and

properties

117

6.3.2 Events 118

6.4 The TextBox Control 126

6.4.1 TextBox Control’s appearance and

properties

126

6.4.2 Events 130

6.4.3 Methods 135

6.5 The MsgBox Statement 136

6.5.1 The syntax for MsgBox Statement 136

6.5.2 The Message Box buttons 139

6.5.3 The Message Box Icons 141

6.5.4 Mixing the Message Box Buttons

and the Message Box Icons

6. 6 Questions

144

148

APPENDIX Appendix A

Installing of Visual Basic .NET 2005

151