Step into Programming with Visual Basic .NET

Edition: 5

Copyright: 2019

Pages: 325

Choose Your Format

Ebook

$91.46

ISBN 9781524991029

Details Electronic Delivery EBOOK 180 days

Step into Programming is written for those with no prior programming experience. The authors cover major programming concepts in a simple and concise language, with thorough explanation and ample examples. All the examples are in Visual Basic .NET 2012. This book is also a quick read for those who have prior programming experience and want to learn Visual Basic .NET.

It is a well known fact that learning how to program for the first time is an overwhelming task for most students. Therefore, having a readable textbook and an effective teaching approach is crucial.

 

Chapter 1 Getting Started

1.1 Getting Visual Basic .NET

1.2 Visual Basic .NET Language

.NET Framework

Visual Basic .NET Programming Language is

A Visual Basic .NET program consists of two major parts

Visual Basic .NET IDE

Files Created in a VB .NET Project

1.3 Getting Started with Visual Basic .NET

Getting Familiar with the IDE

1.4 Three Basic Controls

TextBox Control

Label Control

Button Control

1.5 Important Properties

Name Property

Naming Convention for Objects

Text Property

1.6 Accessing the Property of an Object in the Code

Assignment Operator (_)

String Literal/Constant

My First VB Program

1.7 Program Development Life Cycle (PDLC)

Follow the PDLC for This Example

1.8 What Is an Event?

1.9 String Concatenation &, +

Inserting a Line Feed in the Output String

How to Add Additional Text to the Existing Text in a Label

How to Clear the Text Displayed in a Textbox or Label

1.10 Methods

Focus Method

Clear Method

Close Method

Putting It All Together

Setting the Tab Order of the Objects

Review Questions

Programming Challenges

Chapter 2 Variables

2.1 Introduction

2.2 Data Values in a Program

2.3 Variables

Name

Data Type

Value

Scope

Lifetime

2.4 Variable Naming Rules

Suggested Naming Standards

2.5 Data Types in Visual Basic .NET

String Data Type

Data Types for Numeric Data

Other Data Types in VB .NET

2.6 Deciding Which Data Type to Use

2.7 Variable Definition

Multiple Declarations

How a Declaration Works

2.8 Assignment Operator (=)

2.9 Scope of a Variable

2.10 Lifetime of a Variable

2.11 Comments

Review Questions

Programming Challenges

Chapter 3 Arithmetic Operators

3.1 Introduction

3.2 Arithmetic Operators in VB .NET

Power Operator (^)

Multiplication Operator (*)

Real Division (/)

Integer Division (\)

Modulus Operator (Mod)

Addition and Subtraction Operators (_, _)

3.3 Arithmetic Expression

Precedence Rules

3.4 Arithmetic in VB .NET

Lvalue and Rvalue

Changing the Value Stored in a Variable

What Happens When Operands Are of Different Data Types?

3.5 Combined Assignment Operators

Option Explicit On

Option Strict On

3.6 Explicit-type Conversion

Converting a String to Its Numeric Equivalent

Converting the Numeric Data to String

3.7 Formatting the Numeric Output

3.8 Translating Formulas to VB .NET

3.9 Named Constants

3.10 Different Types of Errors

3.11 Module Scope Identifiers

Counting and Accumulating

Review Questions

Programming Challenges

Chapter 4 Selection

4.1 Introduction

4.2 Using Pseudocode to Write Selection Structures

4.3 Using Flowcharts to Depict Selection Structures

4.4 Relational Operators

Relational Expression or Condition

4.5 If Statement (One-Way Decision)

General Syntax and Flowchart

4.6 If / Else Statement (Two-Way Decision)

General Syntax and Flowchart

4.7 Nested If Statement

If / ElseIf Statement

4.8 Select Case Statement

General Syntax

4.9 Comparing String Data

How Are Characters Stored in the Computer’s Memory?

How to Perform a Case-Insensitive Comparison

4.10 String Manipulation Methods

Length Property

Trim() Method

SubString Method

IndexOf Method

4.11 Logical Operators

Logical Expression

Logical And

Logical Or

Logical Not

Precedence Rule

Review Questions

Programming Challenges

Chapter 5 Data Validation

5.1 Introduction

5.2 Why Use Data Validation

5.3 Using a MessageBox

5.4 Data Validation

Existence Check

Type Check

Range Check

Pattern Check

Code Check

Checking if a RadioButton Is Selected

Validate Selection in a ComboBox

5.5 Major Steps in Validating the Data

Exit Sub

Part A: Existence Check

Part B: Type Check

Part C: Range Check

Part D: Pattern Check

Part E: Code Check

Part F: Radio Button Selection Check

Part G: ComboBox Selection Check

5.6 Exception Handling in VB .NET

Review Questions

Programming Challenges

Chapter 6 Modularity

6.1 Introduction

6.2 Why Modularize?

Advantages of Modularity

Disadvantages

6.3 Modularity in VB .NET

6.4 General Procedures

General Syntax

6.5 Built-In Functions in VB .NET

6.6 General Functions

General Syntax

Invoking the Function

Further Modularization

Modularize the Problem

6.7 Passing Parameters

Pass-By-Value

Pass-By-Reference

When to Use ByVal / ByRef?

6.8 How to Choose between Function and Procedure

Review Questions

Programming Challenges

Chapter 7 Repetition Structures

7.1 Why Use Loops?

7.2 Introduction

7.3 Terminology

7.4 Different Kinds of Loops

Pre-test Loops

Post-test Loops

Repetition Structures in VB .NET

7.5 For. . . Next Loop

Key Points to Remember

For Loop with Negative Step Value

For Loop with a Step Value other than 1

7.6 Do-While. . . Loop

Key Points to Remember

7.7 Do-Until. . . Loop

Key Points to Remember

Post-test Loops

7.8 Do. . . Loop-While

Key Points to Remember

7.9 Do. . . Loop-Until

Key Points to Remember

7.10 Exit Do | Exit For

Infinite Loop

7.11 Do. . . Loop

7.12 Nested Loops

Review Questions

Programming Challenges

Chapter 8 Arrays

8.1 Introduction

8.2 Definition

8.3 Declaring a One-Dimensional Array

8.4 Index | Subscript

8.5 Accessing Array Elements

8.6 Working with One-Dimensional Array

8.7 ListBox Control

Important Properties

Important Methods

8.8 Parallel Arrays

Data Structure

8.9 Displaying the Output in Tabular Format

PadRight(n)

PadLeft(n)

Review Questions

Programming Challenges

Chapter 9 Dynamic and Two-Dimensional Arrays

9.1 Dynamic Arrays

9.2 Declaration

9.3 Resizing a Dynamic Array

How to Shrink a Dynamic Array

Data Structure with Module Scope

9.4 Two-Dimensional Arrays

9.5 More on Arrays

9.6 Searching and Sorting

9.7 Sequential Search

Sequential Search Algorithm

9.8 Bubble Sort

Review Questions

Programming Challenges

Chapter 10 User-Defined Data Types .

10.1 Structure

Declaration Syntax (keywords are in bold)

10.2 Structure Variable

10.3 Accessing the Data Members

10.4 Assigning One Structure Variable to Another

Data Structure

10.5 InputBox Function

The Way the InputBox Works

Review Questions

Programming Challenges

Chapter 11 Multiform Projects

11.1 Introduction

11.2 Adding a Form to a VB .NET Project

Form’s Name Property and Form File Name

11.3 Important Methods of the Form Object

Show() Method

ShowDialog() Method

Close() Method

11.4 Important Events of the Form Object

Form Load Event

Activated Event

Form Closing Event

11.5 Creating the Skeleton of the Event Procedures

in the Code Window

11.6 Global Variables

Code Module

Declaring a Global Identifier

Data Structure

Review Questions

Programming Challenges

Chapter 12 Files

12.1 Introduction

12.2 Input | Output File

12.3 Categories of Files

Sequential Access File

Random Access File

Binary File

12.4 VB .NET Classes and Methods

A Brief Introduction to Object-Oriented Programming

Brief Overview of the .NET and Its Class Library

12.5 Writing Data to the Sequential Access File

12.6 Reading Data from a Sequential Access File

Steps for Reading from a Sequential Access File

Split Method

12.7 Case Study

Review Questions

Programming Challenges

Chapter 13 Exception Handling

13.1 Introduction

13.2 Try-Catch Statement

General Syntax

13.3 The Exception Object

13.4 Try-Catch-Finally Statement

General Syntax

13.5 Using Multiple Catch Blocks

13.6 Understanding the Exception Call Stack

Review Questions

Programming Challenges

Chapter 14 Introduction to Databases

14.1 Introduction

14.2 What Is a Database?

14.3 Access as a RDBMS Example

14.4 VB .NET and MS Access Data Types

14.5 Brief Introduction to ADO .NET 220

Data Source

Data Adapter

DataSet

14.6 Connecting to MS Access Database in VB .NET

Review Questions

Programming Challenges

Appendix A Debugging

A.1 Introduction

A.2 Four Steps to Debugging

A.3 Debugging in VB .NET

Appendix B The Graphical User Interface

B.1 Introduction

B.2 Importance of GUI Guidelines

B.3 General Rules of Thumb for GUI Development

B.4 Windows GUI Development Guidelines

Appendix C Coding Standards

C.1 Introduction

C.2 Why Coding Standards?

C.3 Suggested Coding Standards

Appendix D Additional Controls

D.1 Introduction

D.2 CheckBox Control

D.3 RadioButton Control

D.4 ComboBox Control

D.5 DateTimePicker Control

D.6 PictureBox Control

Appendix E Integrating Excel into VB .NET

E.1 Introduction

E.2 Adding Reference to a COM Object

E.3 Excel Objects

E.4 How to Access an Excel Spreadsheet

E.5 How to Create an Excel Spreadsheet

E.6 How to Manipulate Data in an Excel Sheet

E.7 Two Dimensional Array and Excel

E.8 Saving Data to a CSV File

Appendix F Answers to Review Questions

Guity Ravai

Guity Ravai has a Master’s degree in computer science from the Department of Computer Science at
Purdue University with a concentration in databases. She is a faculty member in the department of
Computer & Information Technology at Purdue University, West Lafayette, Indiana. She has been teaching
computer programming courses using Visual Basic, C, C# and C to undergraduate students since
1998. Currently, Guity teaches all the service programming courses offered in the department along with
the first core programming course for the majors. On average she has more than two hundred students
each semester.

Ibrahim Moussa Baggili

Ibrahim Baggili received his PhD at the College of Technology at Purdue University. He has earned
a Bachelor of Science degree in Computer Technology with a concentration in Network Engineering
Technology and a Master of Science degree in computer programming for mobile platforms. Ibrahim
is currently an Assistant Professor at the University of New Haven (UNH), CT at the Department of
Computer Science - Tagliatela College of Engineering. His area of research and teaching expertise is in
Cyber Forensics and Cyber Criminal investigations. Prior to his post at UNH, Ibrahim was an Assistant
Professor at Zayed University in the UAE at the College of Technological Innovation, where he directed
the Advanced Cyber Forensics Research Laboratory (ACFRL).

Step into Programming is written for those with no prior programming experience. The authors cover major programming concepts in a simple and concise language, with thorough explanation and ample examples. All the examples are in Visual Basic .NET 2012. This book is also a quick read for those who have prior programming experience and want to learn Visual Basic .NET.

It is a well known fact that learning how to program for the first time is an overwhelming task for most students. Therefore, having a readable textbook and an effective teaching approach is crucial.

 

Chapter 1 Getting Started

1.1 Getting Visual Basic .NET

1.2 Visual Basic .NET Language

.NET Framework

Visual Basic .NET Programming Language is

A Visual Basic .NET program consists of two major parts

Visual Basic .NET IDE

Files Created in a VB .NET Project

1.3 Getting Started with Visual Basic .NET

Getting Familiar with the IDE

1.4 Three Basic Controls

TextBox Control

Label Control

Button Control

1.5 Important Properties

Name Property

Naming Convention for Objects

Text Property

1.6 Accessing the Property of an Object in the Code

Assignment Operator (_)

String Literal/Constant

My First VB Program

1.7 Program Development Life Cycle (PDLC)

Follow the PDLC for This Example

1.8 What Is an Event?

1.9 String Concatenation &, +

Inserting a Line Feed in the Output String

How to Add Additional Text to the Existing Text in a Label

How to Clear the Text Displayed in a Textbox or Label

1.10 Methods

Focus Method

Clear Method

Close Method

Putting It All Together

Setting the Tab Order of the Objects

Review Questions

Programming Challenges

Chapter 2 Variables

2.1 Introduction

2.2 Data Values in a Program

2.3 Variables

Name

Data Type

Value

Scope

Lifetime

2.4 Variable Naming Rules

Suggested Naming Standards

2.5 Data Types in Visual Basic .NET

String Data Type

Data Types for Numeric Data

Other Data Types in VB .NET

2.6 Deciding Which Data Type to Use

2.7 Variable Definition

Multiple Declarations

How a Declaration Works

2.8 Assignment Operator (=)

2.9 Scope of a Variable

2.10 Lifetime of a Variable

2.11 Comments

Review Questions

Programming Challenges

Chapter 3 Arithmetic Operators

3.1 Introduction

3.2 Arithmetic Operators in VB .NET

Power Operator (^)

Multiplication Operator (*)

Real Division (/)

Integer Division (\)

Modulus Operator (Mod)

Addition and Subtraction Operators (_, _)

3.3 Arithmetic Expression

Precedence Rules

3.4 Arithmetic in VB .NET

Lvalue and Rvalue

Changing the Value Stored in a Variable

What Happens When Operands Are of Different Data Types?

3.5 Combined Assignment Operators

Option Explicit On

Option Strict On

3.6 Explicit-type Conversion

Converting a String to Its Numeric Equivalent

Converting the Numeric Data to String

3.7 Formatting the Numeric Output

3.8 Translating Formulas to VB .NET

3.9 Named Constants

3.10 Different Types of Errors

3.11 Module Scope Identifiers

Counting and Accumulating

Review Questions

Programming Challenges

Chapter 4 Selection

4.1 Introduction

4.2 Using Pseudocode to Write Selection Structures

4.3 Using Flowcharts to Depict Selection Structures

4.4 Relational Operators

Relational Expression or Condition

4.5 If Statement (One-Way Decision)

General Syntax and Flowchart

4.6 If / Else Statement (Two-Way Decision)

General Syntax and Flowchart

4.7 Nested If Statement

If / ElseIf Statement

4.8 Select Case Statement

General Syntax

4.9 Comparing String Data

How Are Characters Stored in the Computer’s Memory?

How to Perform a Case-Insensitive Comparison

4.10 String Manipulation Methods

Length Property

Trim() Method

SubString Method

IndexOf Method

4.11 Logical Operators

Logical Expression

Logical And

Logical Or

Logical Not

Precedence Rule

Review Questions

Programming Challenges

Chapter 5 Data Validation

5.1 Introduction

5.2 Why Use Data Validation

5.3 Using a MessageBox

5.4 Data Validation

Existence Check

Type Check

Range Check

Pattern Check

Code Check

Checking if a RadioButton Is Selected

Validate Selection in a ComboBox

5.5 Major Steps in Validating the Data

Exit Sub

Part A: Existence Check

Part B: Type Check

Part C: Range Check

Part D: Pattern Check

Part E: Code Check

Part F: Radio Button Selection Check

Part G: ComboBox Selection Check

5.6 Exception Handling in VB .NET

Review Questions

Programming Challenges

Chapter 6 Modularity

6.1 Introduction

6.2 Why Modularize?

Advantages of Modularity

Disadvantages

6.3 Modularity in VB .NET

6.4 General Procedures

General Syntax

6.5 Built-In Functions in VB .NET

6.6 General Functions

General Syntax

Invoking the Function

Further Modularization

Modularize the Problem

6.7 Passing Parameters

Pass-By-Value

Pass-By-Reference

When to Use ByVal / ByRef?

6.8 How to Choose between Function and Procedure

Review Questions

Programming Challenges

Chapter 7 Repetition Structures

7.1 Why Use Loops?

7.2 Introduction

7.3 Terminology

7.4 Different Kinds of Loops

Pre-test Loops

Post-test Loops

Repetition Structures in VB .NET

7.5 For. . . Next Loop

Key Points to Remember

For Loop with Negative Step Value

For Loop with a Step Value other than 1

7.6 Do-While. . . Loop

Key Points to Remember

7.7 Do-Until. . . Loop

Key Points to Remember

Post-test Loops

7.8 Do. . . Loop-While

Key Points to Remember

7.9 Do. . . Loop-Until

Key Points to Remember

7.10 Exit Do | Exit For

Infinite Loop

7.11 Do. . . Loop

7.12 Nested Loops

Review Questions

Programming Challenges

Chapter 8 Arrays

8.1 Introduction

8.2 Definition

8.3 Declaring a One-Dimensional Array

8.4 Index | Subscript

8.5 Accessing Array Elements

8.6 Working with One-Dimensional Array

8.7 ListBox Control

Important Properties

Important Methods

8.8 Parallel Arrays

Data Structure

8.9 Displaying the Output in Tabular Format

PadRight(n)

PadLeft(n)

Review Questions

Programming Challenges

Chapter 9 Dynamic and Two-Dimensional Arrays

9.1 Dynamic Arrays

9.2 Declaration

9.3 Resizing a Dynamic Array

How to Shrink a Dynamic Array

Data Structure with Module Scope

9.4 Two-Dimensional Arrays

9.5 More on Arrays

9.6 Searching and Sorting

9.7 Sequential Search

Sequential Search Algorithm

9.8 Bubble Sort

Review Questions

Programming Challenges

Chapter 10 User-Defined Data Types .

10.1 Structure

Declaration Syntax (keywords are in bold)

10.2 Structure Variable

10.3 Accessing the Data Members

10.4 Assigning One Structure Variable to Another

Data Structure

10.5 InputBox Function

The Way the InputBox Works

Review Questions

Programming Challenges

Chapter 11 Multiform Projects

11.1 Introduction

11.2 Adding a Form to a VB .NET Project

Form’s Name Property and Form File Name

11.3 Important Methods of the Form Object

Show() Method

ShowDialog() Method

Close() Method

11.4 Important Events of the Form Object

Form Load Event

Activated Event

Form Closing Event

11.5 Creating the Skeleton of the Event Procedures

in the Code Window

11.6 Global Variables

Code Module

Declaring a Global Identifier

Data Structure

Review Questions

Programming Challenges

Chapter 12 Files

12.1 Introduction

12.2 Input | Output File

12.3 Categories of Files

Sequential Access File

Random Access File

Binary File

12.4 VB .NET Classes and Methods

A Brief Introduction to Object-Oriented Programming

Brief Overview of the .NET and Its Class Library

12.5 Writing Data to the Sequential Access File

12.6 Reading Data from a Sequential Access File

Steps for Reading from a Sequential Access File

Split Method

12.7 Case Study

Review Questions

Programming Challenges

Chapter 13 Exception Handling

13.1 Introduction

13.2 Try-Catch Statement

General Syntax

13.3 The Exception Object

13.4 Try-Catch-Finally Statement

General Syntax

13.5 Using Multiple Catch Blocks

13.6 Understanding the Exception Call Stack

Review Questions

Programming Challenges

Chapter 14 Introduction to Databases

14.1 Introduction

14.2 What Is a Database?

14.3 Access as a RDBMS Example

14.4 VB .NET and MS Access Data Types

14.5 Brief Introduction to ADO .NET 220

Data Source

Data Adapter

DataSet

14.6 Connecting to MS Access Database in VB .NET

Review Questions

Programming Challenges

Appendix A Debugging

A.1 Introduction

A.2 Four Steps to Debugging

A.3 Debugging in VB .NET

Appendix B The Graphical User Interface

B.1 Introduction

B.2 Importance of GUI Guidelines

B.3 General Rules of Thumb for GUI Development

B.4 Windows GUI Development Guidelines

Appendix C Coding Standards

C.1 Introduction

C.2 Why Coding Standards?

C.3 Suggested Coding Standards

Appendix D Additional Controls

D.1 Introduction

D.2 CheckBox Control

D.3 RadioButton Control

D.4 ComboBox Control

D.5 DateTimePicker Control

D.6 PictureBox Control

Appendix E Integrating Excel into VB .NET

E.1 Introduction

E.2 Adding Reference to a COM Object

E.3 Excel Objects

E.4 How to Access an Excel Spreadsheet

E.5 How to Create an Excel Spreadsheet

E.6 How to Manipulate Data in an Excel Sheet

E.7 Two Dimensional Array and Excel

E.8 Saving Data to a CSV File

Appendix F Answers to Review Questions

Guity Ravai

Guity Ravai has a Master’s degree in computer science from the Department of Computer Science at
Purdue University with a concentration in databases. She is a faculty member in the department of
Computer & Information Technology at Purdue University, West Lafayette, Indiana. She has been teaching
computer programming courses using Visual Basic, C, C# and C to undergraduate students since
1998. Currently, Guity teaches all the service programming courses offered in the department along with
the first core programming course for the majors. On average she has more than two hundred students
each semester.

Ibrahim Moussa Baggili

Ibrahim Baggili received his PhD at the College of Technology at Purdue University. He has earned
a Bachelor of Science degree in Computer Technology with a concentration in Network Engineering
Technology and a Master of Science degree in computer programming for mobile platforms. Ibrahim
is currently an Assistant Professor at the University of New Haven (UNH), CT at the Department of
Computer Science - Tagliatela College of Engineering. His area of research and teaching expertise is in
Cyber Forensics and Cyber Criminal investigations. Prior to his post at UNH, Ibrahim was an Assistant
Professor at Zayed University in the UAE at the College of Technological Innovation, where he directed
the Advanced Cyber Forensics Research Laboratory (ACFRL).