Exploring the Visual Studio Integrated Development Environment Part I Chapter 1 Exploring the Visual Studio Integrated Development Environment
Objectives Understand software and computer programs Define Microsoft Visual Basic and identify the common features of Windows applications. Identify and use the basic tools in the Visual Studio .NET integrated development environment. Design a form and add objects to it. Explain the meaning of "event-driven" and write code for an event procedure. Understand and use the Help system.
Vocabulary Builds Class Code Controls Dialog box Event-driven Event procedure Events File extension Form Graphical user interface (GUI) Instantiation Integrated development environment (IDE) Menus Method Objects Properties Solution ToolTip
Historically Speaking The first general‑purpose computer of the modern age was the ENIAC—The Electronic Numerical Integrator and Computer. It was invented to do only one thing, calculate firing tables for missiles in the Second World War. The ENIAC consisted of more than 18,000 vacuum tubes and filled a large room. To program the ENIAC, it had to be completely rewired. It was a far cry from what we have today. Its inventors, J. Eckert and John Mauchley, went on to found the first American computer company called UNIVAC.
Introduction The set of instructions that directs a computer to perform tasks is called computer software, or a computer program Chapter 1: Introduction to Visual Basic 2005 Programming
Introduction Computer hardware is the physical equipment associated with a computer Chapter 1: Introduction to Visual Basic 2005 Programming
Introduction The basic function of many computer programs is to accept data, manipulate the data (process), and create output data or information Chapter 1: Introduction to Visual Basic 2005 Programming
Introduction In order for the computer to execute a program: Program and data must be placed in the computer’s random access memory (RAM) The central processing unit (CPU) can access the instructions in the program and the data in RAM to perform activities directed by the program Chapter 1: Introduction to Visual Basic 2005 Programming
Introduction Saving, or storing, data refers to placing the data or software electronically on a storage medium Hard disk Universal Serial Bus (USB) drive Persistent data remains available even after the computer power is turned off Chapter 1: Introduction to Visual Basic 2005 Programming
Computer Programmers and Developers A computer program is designed and developed by people known as computer programmers, or developers Developers are people skilled in designing computer programs and creating them using programming languages Applications may consist of several computer programs working together to solve a problem Computer programmers write the code for programs using a programming language Chapter 1: Introduction to Visual Basic 2005 Programming
Computer Programmers and Developers Chapter 1: Introduction to Visual Basic 2005 Programming
Event-Driven Computer Programs with a Graphical User Interface Most Visual Basic 2005 programs are event-driven programs that communicate with the user through a graphical user interface (GUI) A GUI usually consists of a window, containing a variety of objects An event means the user has initiated an action that causes the program to perform the type of processing called for by the user’s action Chapter 1: Introduction to Visual Basic 2005 Programming
Event-Driven Computer Programs with a Graphical User Interface For example: The user enters the account number in the Account Number box The user clicks the Display Account Balance button The user clicks the Reset Window button to clear the text boxes and prepare the user interface for the next account number Chapter 1: Introduction to Visual Basic 2005 Programming
Input Operation Chapter 1: Introduction to Visual Basic 2005 Programming
Output Operation Chapter 1: Introduction to Visual Basic 2005 Programming
Visual Basic 2005 and Visual Studio 2005 Chapter 1: Introduction to Visual Basic 2005 Programming
Programming Languages Visual Basic 2005 Based on the Visual Basic programming language that Microsoft developed in the early 1990s Based on the BASIC language C++ Derivative of the programming language, C Visual C# Synthesis of C++ syntax and Visual Basic productivity benefits Visual J# Java language for use with Visual Studio Chapter 1: Introduction to Visual Basic 2005 Programming
.NET Framework 2.0 .NET technologies and products were designed to work together to allow businesses to connect information, people, systems, and devices through software The .NET Framework provides tools and processes developers can use to produce and run programs Most recent version is .NET Framework 2.0 Chapter 1: Introduction to Visual Basic 2005 Programming
.NET Class Library A class is a named group of program code A button is an example of a class A class library stores the class and makes the class available to all developers who need to use it Chapter 1: Introduction to Visual Basic 2005 Programming
.NET Class Library A button created from a class is called an object, or sometimes an instance of a class The process of creating a Button object from the Button class is called instantiation Rapid application development (RAD) refers to the process of using prebuilt classes to make application development faster, easier, and more reliable Chapter 1: Introduction to Visual Basic 2005 Programming
ADO.NET 2.0 ADO.NET 2.0 (ActiveX Data Objects) provides the functionality for a program to perform four primary tasks when working with a database: Get the data Examine the data Edit the data Update the data Chapter 1: Introduction to Visual Basic 2005 Programming
ASP.NET 2.0 Allows developers to use Visual Studio 2005 to build Web application Almost all .NET framework objects are available in ASP.NET 2.0 Easy to deploy a Web application on a Web server Chapter 1: Introduction to Visual Basic 2005 Programming
Microsoft Intermediate Language (MSIL) and Common Language Runtime (CLR) Program compilation translates programming statements into instructions that can be understood by the electronics of the computer Program compilation for a Visual Basic 2005 program creates a set of electronic code expressed in an intermediate language called the Microsoft Intermediate Language (MSIL) When the program is executed, a portion of .NET 2.0 called the Common Language Runtime (CLR) reads the MSIL and causes the actual instructions within the program to be executed Chapter 1: Introduction to Visual Basic 2005 Programming
Microsoft Intermediate Language (MSIL) and Common Language Runtime (CLR) Chapter 1: Introduction to Visual Basic 2005 Programming
Types of Visual Basic 2005 Applications Windows application Program will run on a computer or other device that supports the Windows GUI Mobile application Designed to run on mobile devices running the Windows CE operating system Web site application Uses ASP.NET 2.0 and runs on a Web server Chapter 1: Introduction to Visual Basic 2005 Programming
Types of Visual Basic 2005 Applications Office application Includes Writing Visual Basic 2005 code to automate and manipulate documents created using Microsoft Office Database application Written using ADO.NET 2.0 to reference, access, display, and update data stored in a database Other types of applications include console applications, classes for class libraries, Web services, and device-specific applications Chapter 1: Introduction to Visual Basic 2005 Programming
Common Windows Objects Minimize button Title bar Menu bar Menu Maximize/Restore Point out the Title bar, Menu bar, Toolbar, Menu and menu commands, Minimize button, and Maximize/Restore button Toolbar
Shortcut Keys for File Menu Commands
Visual Studio Integrated Development Environment (IDE)
New Project Dialog Box
An Empty Visual Basic Project in the Visual Studio IDE
Note Each application program is called a project. Some applications require more than one project. The collection of projects that form an application is called a solution. The Solution Explorer shows the files and components that make up the solution.
The Visual Basic Standard Toolbar
Note The Tools menu and the Toolbox window may vary from system to system due to different system configurations.
The Standard Toolbar Showing the Add New Item ToolTip
Note ToolTips give a short explanation of what a control does. They appear as yellow boxes near a control when your mouse pointer rests over the control
The Add New Item Box Figure 1-8
Note Menu commands and buttons appear in color or solid black when they can be used and are grayed out when they cannot be used.
The Visual Basic Toolbox Figure 1-9
Building Communication Skills Before starting any project, it is important to make sure that you, the programmer, understand exactly what your client expects from the program. One of the best ways of making this happen is to interview the client or the client's users. Do not assume that, just because you think something should be done one way, the client thinks the same thing. Building Communication Skills
Note Attaching your program tools to a particular place in the development environment is called docking.
Note Double‑click a tool in the Toolbox and a control of default size appears on the form.
Understanding the Solution Explorer Window The Solution Explorer window lists all of the forms and modules used in the project or projects that make up the complete application called the solution.
The Solution Explorer Window
Examining the Properties Window Like any physical object, each object in Visual Basic has properties. The properties describe the object's appearance, position, and behavior. The Properties window lists the characteristics for the selected form or object. The left column displays the names of the properties associated with the selected object and the right column displays the current setting for that property.
Properties Window
Building Programming Skills Despite legal battles that have embroiled Microsoft over the last few years, the company has brought a level of continuity to the PC environment. Windows users, as a result, have come to expect certain things when they launch a Windows application. It would be unwise for a programmer who wanted to sell an application to deviate from industry standards.
Tip An easy way to change a property setting is to double‑click the property's name (not the name of the object) in the left column. The property setting is selected and ready to be replaced. Once selected, just keying a new value from the keyboard will replace the old value. Double-clicking a property's name in the left column of the Properties window may change the property's value by cycling through the possible values.
Tip The properties are listed in alphabetical order with the exception of Name, which is at the top. While each object has its own unique set of properties, every object has a Name property. Visual Basic automatically gives each object a name when it is created, but the values are not particularly descriptive (for example, Form1). It is a good idea to give each object a more descriptive name after adding it to the project because you use the object's Name property when writing code.
Computer Ethics As a programmer, it is important to remember to give credit where credit is due. If you use someone else's work, make sure you have permission to use their work and give them credit for it.
The Visual Basic Project A Visual Basic project is composed of all the forms, controls, code, and other items that make up the entire application. You may also want to add prebuilt components to your application. By using all of the tools available to you, powerful applications can be created quickly and efficiently.
Creating a Form The form may have buttons, scroll bars, menus, list boxes, menus, and any of the other features that are common to Windows programs. Forms are the main building blocks of an application. You begin by creating the forms, adding the controls, writing the code, testing the application, and then finally using it in its actual setting. Proper planning helps ensure that users will be able to quickly find their way around a program. It is the programmer's responsibility to consider the multitude of users that may access their program and anticipate all of the different options that they may need.
Note In Microsoft Word, you may close a document before closing Word, although it is unnecessary to do so. You might be tempted to right-click the project name in the Solution Explorer and select Remove to remove the current project from Visual Basic; do not do so. Later in the book, you will have two projects open at the same time. This creates a solution with multiple projects. The Remove Project command is meant to remove a second (or third) project from a solution. It is not meant to remove a project at the end of a programming session.
Class Name List Box Figure 1-12
Note If you click the Class Name list box, you will see four entries: Form1 (MyFirst), (Overrides), IblHello, and Form1. Form1 and IblHello correspond to the objects that are available to this application at this point. If you were to add additional controls, they would be listed here as well.
Summary Microsoft Visual Basic .NET is a set of programming tools that allows you to create applications for the Windows operating system and for the Internet. Programs in Visual Basic are event‑driven. Users initiate an event with a mouse click or by pressing a key. The code written by a programmer to respond to an event is called a method. The Solution Explorer lists all the files and modules that make up an application. It may contain information about more than one project. The toolbar provides easy access to frequently performed commands. A number of specialized toolbars can be displayed to make other commands readily available.
Summary The Toolbox contains many controls that you can add to your forms. More controls can be added to the Toolbox to give you even greater capabilities. The Properties window lists the properties information for a selected form or object. Standard prefixes have been developed for commonly used controls. It is important to give all objects descriptive names. Build the names with the appropriate prefix followed by one or more words starting with uppercase letters. The word(s) should describe the control’s use.
Summary A Visual Basic project is composed of all the forms, controls, code, and other items that make up an application. Use the Solution Explorer to view those components. Files are designated by the filename, a period, and the file extension. Programs in Windows work based on messages that generate events for the application. Each event executes code contained in the event’s method. Select items in the Debug menu to run the program. To exit Visual Basic, choose Exit from the File menu or click the Close button on the title bar.