Programming In Visual Basic 2008 Solutions Manual

Posted : admin On 21.12.2019
Programming In Visual Basic 2008 Solutions Manual Rating: 3,6/5 3467 reviews

Chapter 1. Solutions and Projects The first product Microsoft ever built was a Basic interpreter for the Altair 8800 personal computerso they’ve had a lot of years to perfect their development tools. That time has not been wasted. Visual Studio.NET is the culmination of more than a decade of work on Visual C, Visual Basic, Visual InterDev, and Visual J. Honda trx 350 red 2016 manual.

In this chapter, we will introduce the foundation of all VS.NET-based software development: solutions and projects. Everything that you do with VS.NET will revolve around these two concepts, so a sound understanding of these is central to making effective use of this tool. To build anything with Visual Studio.NET, you need to use a solution, and that solution must contain at least one project. Solutions are the containers for all your work in VS.NET. A solution contains a project for each build output. (For example, if you want to build a DLL, an EXE, and an MSI Installer file, your solution will contain three projects.) Projects themselves contain source files.

In this chapter, you will learn the ins and outs of solutions and projects and how to use them as effectively as possible. Figure 1-2. Projects that belong to multiple solutions With Microsoft’s previous generation of development tools, each language had its own integrated development environment. Now there is just one unified environment. In addition, there are no restrictions on the range of different project types any single solution can contain, so you can work on, say, an unmanaged C DLL in the same solution as a VB.NET Window Forms application, which can greatly simplify development, debugging, and deployment. But before we get too excited about that, let us see how to create a solution. Creating a Solution A new solution may be created in many ways in VS.NET. The simplest is to create a new project—by default, Visual Studio.NET will create a new solution with the same name as the project, placing the solution files in the same directory as the project.

Although this works fine for small projects, it isn’t well suited to more complex applications. Since a solution is a container of projects, it does not make sense for the solution file to be inside the project directory. For multiproject solutions, having the directory structure reflect the solution structure usually makes more sense—it is best to have a directory that contains your solution file, with subdirectories for each individual project. Visual Studio.NET is happy to create this type of directory structure for you. When you create a new project by using the New Project dialog box (Ctrl-Shift-N), you can bring up additional options by clicking on the More button in the lower-lefthand corner of the dialog. These options are shown in.

(The More button turns into a Less button when the extra options are visible.) If you select the Create directory for Solution checkbox, Visual Studio.NET will not place the solution files in the same directory as the project. Instead, it will create a folder for your solution and inside this will create a second folder containing your project. The New Solution Name text box determines the name of both the solution and the solution folder. (You pick the project template you want to create as your first project and type its name in the Name text box as usual.). Tip You cannot select the Create directory for Solution option when creating a new ASP.NET project.

With web projects, you will need to create a blank solution first in order to make your directory structure match your solution structure. To create a blank solution, use File →New →Blank Solution—this will show the New Project dialog box with the Blank Solution template selected (see ). You can use the Location text box to choose the path for this New Solution Name and the Name text box to give it a name. A folder with your chosen name will be created at the specified path, and a new solution file (with the same name as the folder) will be placed there.

Figure 1-4. Blank Solution dialog box Matching the file structure of a solution and its contained projects to the logical structure has the advantage of making it easier to put together a zip file of the whole solution. Consider what happens if you just allow VS.NET to put new projects in the default locations when you create a new project and then add a second project to the solution. If you zip the first project directory, the zip file will contain the solution file, but that solution file will refer to the second project directory.

Programming In Visual Basic 2008 Solutions Manual

However, the second project directory will not be present in the zip file, because, by default, VS.NET will make it a peer of the first project directory instead of a child. However, if you make the directory structure reflect the logical structure, with the project directories all being children of the solution directory, you can simply zip up the solution directory, and the zip file will contain all of the projects that belong to the solution. Illustrates how the physical directory structure can reflect the logical structure of a project. Shows how Visual Studio.NET will organize the directory structure if left to its own devices—the physical structure is less closely related to the logical structure.

The solution file is located in an arbitrary project directory. (Specifically, it is in the first project that was created in the solution.) The project directories themselves may well be in the same directory as other, unrelated directories or files. So, to avoid the mess shown in, be sure to check the Create directory for solution checkbox.

Saving Web-Based Projects By default, VS.NET creates all new solutions beneath the Visual Studio Projects folder inside of your My Documents folder. However, it is a bad idea to put solutions that contain web-based projects here. Visual Studio.NET requires web projects to reside in a directory with Web Sharing enabled, and in Windows XP, you cannot turn on Web Sharing for directories underneath the My Documents folder. A certain amount of planning is required if you want to keep control over where web projects end up, because although the default locations chosen by VS.NET for your files will work, they may not be the locations you were expecting, particularly if you let it create a new solution for a new web project.

Programming In Visual Basic

When you create a new web-based project, VS.NET communicates with the web server and checks to see whether an application already exists for the URL you specified. If not, it creates a new folder for the project under the root folder of the web server (which is usually%SystemDrive% inetpub wwwroot). The solution files, however, will be elsewhere—if you allow VS.NET to create a new solution for your web project (and it will by default), it will create a directory for your solution in the default location, underneath your My Documents folder. It offers you no choice over the location and doesn’t even tell you where it will go!

If you want to remain in control of the location of your web projects and their solutions, you must first create a new blank solution. Then use Windows Explorer to create a folder for your web-based project inside of your solution folder. Enable web sharing on the new folder using the Web Sharing tab on the folder’s property page, as shown in. (You can get to the property page by right-clicking on the folder in Windows Explorer and selecting Properties.) Alternatively, you can use the IIS administration tool to set the new directory up as a web application.

Figure 1-7. Web Sharing properties page Once you have created the web shared folder, add a new web project to your solution. (Use File → Add Project → New Project. Alternatively, use the New Project dialog (Ctrl-Shift-N) but select the Add to Solution radio button—this will add the new project to your existing blank solution instead of creating a new solution.) You must specify the URL of the web share you created as the project location. This will cause Visual Studio.NET to use your existing web folder instead of creating a new one.

When you create web projects in this way, all of the files needed for that web project and the solution that contains it are kept in one place rather than two. Tip Your copy of Visual Studio.NET may have even more project types—third-party add-ins can extend the list. You can also add your own project templates—see. A managed local project will create a.NET assembly. Managed web projects do the same, but the project output is intended to be accessed by a client over a network connection, typically using either a browser or a web service proxy.

Web projects are therefore always associated with a web application on a web server. And although managed web projects produce a.NET assembly just like a managed local project, with a web project, Visual Studio.NET will place the assembly on the web server as part of the build process. Tip A web project can reside on either a remote web server or the web server on your local machine.

Visual Studio.NET does not make any distinction between these two styles of development. However, if you use a remote server, you may need to modify its security settings in order to debug a web application successfully. See for more information on debugging web applications. Smart Device projects are available only in C# and VB.NET, and they build applications that target Pocket PCs and other mobile devices. These projects are not available with VS.NET 2002. An unmanaged local project builds an unmanaged file (.dll or.exe).

An unmanaged web project is the unmanaged counterpart of the managed web project type, in that its output will be deployed to and run from a web server. Setup projects are used to create Windows Installer (.msi) files that can be used to deploy the final output of your solution. Tip Windows Forms applications were not supported in MC in VS.NET 2002 either, although it was technically possible to use the Managed C Application project type to build a Windows Forms application. This project type is really meant for building console applications, but if you didn’t mind writing by hand all of the code that would normally be generated by the forms designer in C# and VB.NET projects, you could also use it to build Windows Forms applications. In VS.NET 2003, this is no longer necessary, as the Windows Forms Designer now supports MC. The MC project templates are in.

Note that the names of these project types changed between VS.NET 2002 and VS.NET 2003, so both names are given in the table. Managed web-based In a managed web-based project, the build output is copied to a web server and will run on that web server. (The web server can be either the one on your local machine or a remote server.) Of course, a web application typically needs more than just a compiled.NET assembly to run—there are usually files containing content such as.css and.html files, image files such as.gif or.jpeg files, and often files containing a mixture of code and content, such as.aspx files, that must be present on the server. So Visual Studio.NET does not just copy the compiled assembly to the web server—the entire project resides there.

Note Arguably, slightly too much resides on the web server. Visual Studio.NET uses a web project’s associated web server folder as the canonical location for all project files, not just the ones that need to be there. So you will find all of your source files on the server along with the content and build output. This is because, conceptually, a web project doesn’t store any of its files locally—the whole project lives on the web server. Source files are cached locally so that you can edit them and so that the compiler can compile them, but the permanent home of all project members and all build output is the web server. If the prospect of storing the source for your web projects on the web server frightens you, don’t worry—they need to be present on only development servers, not the live server.

If you use a Setup and Deployment project to build an. Msi file to install your project, only files needed by the web application to run will be included. So if you use this. Msi to deploy the project on a server, the source files will not be installed. (Also, ASP.NET is configured not to serve out source files by default, so even on your development server, attempts to download the source using HTTP will fail.) If you don’t like.

Msi files, VS.NET is also able to perform the deployment itself directly. If you select a web project in the Solution Explorer and then select Project → Copy Project. From the main menu, VS.NET will show the Copy Project dialog. This allows you to copy a web project’s files to another web server, and it provides you with the option to copy either all of the files or just the files the web application requires to run. MC has only one project template in this group: ASP.NET Web Service (.NET).

(VS.NET 2002 called this project type Managed C Web Service.) This project type is essentially the same as the VB.NET, J#, and C# ASP.NET Web Service project. All of the VB.NET, J#, and C# managed web-based projects are shown in.

Smart Device Smart Device projects allow you to build applications that run on palmtop devices. These project types are not available on Visual Studio.NET 2002, and they target only C# and VB.NET. Each language lists just one Smart Device project. However, both the C# and VB.NET Smart Device projects open a wizard that allows you to target either the Pocket PC or the Windows CE platform, creating either a Windows Application, a Class Library, a Nongraphical Application, or an Empty Project.

2008

VS.NET ships with an emulator that enables you to test and run your applications on your PC without needing a real PDA. Detailed discussion of palmtop development is beyond the scope of this book. For more information on developing Windows Forms applications on the.NET Compact Framework, please see Essential Windows Forms (Addison-Wesley). Library Project template Project output Type of file built ATL ATL Project An unmanaged executable that uses the ATL DLL or EXE MFC ActiveX Control An ActiveX Control built using MFC DLL MFC Application An MFC Windows Application EXE MFC DLL A DLL that uses MFC DLL MFC ISAPI Extension An ISAPI Extension DLL that uses MFC DLL Win32 Win32 Project A simple Win32-based DLL or EXE EXE or DLL You may be surprised to see the MFC ISAPI Extension project listed as a local project, not a web project. But the defining feature of a web project is that it is associated with a particular web application on a server. MFC ISAPI Extension projects do not copy their build output to a web server—they work like any other local project.

It is up to you to work out how to deploy the extension to a server. Unmanaged web-based Two ATL web-based projects, ATL Server Project and ATL Server Web Service, let you build web applications and web services, respectively. Both kinds of project build ISAPI extensions, using the ATL Server classes.

(These classes were added to the ATL to coincide with the release of VS.NET.) Like managed web-based projects, these projects connect directly to your web server and can contain other types of files than just the DLLs. To learn more about building unmanaged web-based projects with the ATL Server classes, see ATL Internals, Second Edition (Addison-Wesley). Warning If you use the Ctrl-Shift-N shortcut to add a new project to an existing solution, make sure you select the Add to Solution radio button. By default, the Close Solution button will be selected, which will close your solution and create a brand-new solution for the new project! You can avoid this entirely by using the context menu in the Solution Explorer as described earlier or with File → Add Project → New Project.

From the main menu. Both menu options show the Add New Project dialog box, which is almost identical to the New Project dialog box, except it will never close an existing solution. Unfortunately, there is no keyboard shortcut for this dialog. Shows a typical example—a solution called WebManage containing three projects: a Class Library project named BusObj, an ASP.NET Web Application named WebUI, and a Windows Application named WinFormsUI.

Shows how this looks in the Solution Explorer. Adding an existing file Sometimes you will want to add an existing file to a project. For example, if you have downloaded some sample code from MSDN, you may want to add one of the sample’s files to a project of your own. To add an existing file, go to the Project menu and select Project → Add Existing Item.

(Alternatively, select Add → Add Existing Item. From the project’s context menu in the Solution Explorer. Or just use the Shift-Alt-A shortcut.) When you add an existing item, Visual Studio.NET will either use the existing file directly or copy the file into the project directory.

The behavior it chooses depends on the type of project and where the file is located. Shows the behavior of the various project types. Project or folder type Behavior when adding existing items Solution Items folder Uses original.NET Project (VB.NET, C# or J#) Depends (see later), but usually makes copy.NET Web Project (VB.NET, C# or J#) Depends (see later), but usually makes copy Visual C.NET Uses original With VB.NET, C#, and J# projects, if the file is already inside the project directory, no copy will be made. Otherwise, VS.NET will copy the file into the project directory. If you would like to force VS.NET to use the original file when it would normally make a copy, you can choose to link the file instead.

If you look at the Open button on the Add Existing Item dialog, you will see that it has a drop-down arrow on its right. If you click on this, it pops up a menu with a Link File option. If you select this option, VS.NET will add the original file to the project, even when it would otherwise have made a copy. Removing or deleting a file You can remove a file from a solution by highlighting it in the Solution Explorer and selecting Delete, either from the main Edit menu or from the file’s context menu in the Solution Explorer. (You can also just press the Delete key.) For some project types, there will be a Remove option instead of a Delete option.

Basic

Whether you see Remove or Delete will depend on the project type—VB.NET and C# projects offer Delete, everything else offers Remove. Either Delete or Remove will take the item out of the project’s list of files, but Remove will leave the file in the directory, while Delete moves the file to the Recycle Bin. Although C# and VB.NET projects provide the destructive Delete option instead of Remove, you may still remove an item from these project types nondestructively.

Instead of selecting Delete, you can select Exclude from Project. (This is available both from the file’s context menu and from the main Edit menu.) This takes the file out of the project but leaves the file in place on your hard drive—in other words, this does exactly what Remove does on other project types. File properties You can see a file’s properties in the properties window by selecting the file in the Solution Explorer. (You can move the focus to the properties window by pressing the F4 key.) The properties shown will depend on the type of file and the type of project. Most files have very few properties, and the only properties common to all files regardless of type are Name and FullPath (those being the name of and path to the file).

We will discuss type-specific file properties as we look at the individual file types in question. Solution Items Some files do not belong to any particular project in a solution. For example, you may have a solution that contains multiple web applications, all of which share a single Cascading Stylesheet (.css) file.

You could arbitrarily pick one of the projects and make the file a member of it, but this does not accurately reflect how the file is used and could confuse other developers who use your code. Fortunately, you don’t have to do this. Visual Studio.NET lets you add files to a solution without making them a member of any particular project. Such files are called solution items. Tip Solution items will not be compiled. Only files that belong to projects are compiled. Solution items are therefore typically some form of content or documentation.

You can add a solution item by selecting the Solution node in the Solution Explorer then using Add New Item (Ctrl-Shift-A) from the File menu to create a new solution item or Add Existing Item (Shift-Alt-A) to add an already existing file to the solution items. You can add any file type you like to a solution. Shows how VS.NET displays solution items in the Solution Explorer. Figure 1-11. Solution items in the Solution Explorer If you use the Add New Item dialog box to create a new solution item, the new file will be created inside of your solution’s folder. If you use the Add Existing Item dialog box, however, the items can live in any folder (i.e., you can add files that do not live in your solution folder). This is useful because it allows you to give yourself easy access to files in projects outside of your solution. Suppose you are writing a program that consumes a web service.

It may be useful to have access to the WSDL file for that service. (A WSDL file is an XML file containing a detailed formal description of the facilities offered by a web service.) This WSDL file will not be part of your client project—it will be supplied by the web service itself. Although you can just go and find the file with the File Open dialog box every time you want to look at it, this gets old fast. You could also simply include the Web Service project in your solution, but that may slow down your load time and would also make it easier to modify and rebuild the project by accident. But if you just add the WSDL file to your solution as a solution item, it will be available in the Solution Explorer whenever you need it, without the need to include the project in the solution you are working on. Miscellaneous Files Visual Studio.NET will let you open and edit files that do not belong to any project and that are not solution items—you can open any file with File → Open or by dragging a file into VS.NET from Windows Explorer.

This is useful because it allows you to edit files with a minimum of fuss. VS.NET calls these files miscellaneous files. You can get VS.NET to display all open miscellaneous files in the Solution Explorer. If you open the Options dialog box (Tools → Options) and expand the Environment folder, you will see a Documents item on the left.

When you select this, one of the options presented on the right is “Show Miscellaneous Files in Solution Explorer.” If you check this, any open files that do not belong to a project and are not listed in the Solution Items will appear in a folder labeled Miscellaneous Files in the Solution Explorer. With.NET projects, it causes Visual Studio.NET to tell the compiler that your code uses the component, enabling you to use the types it contains—if you don’t have the appropriate references in your project, you will get compiler errors complaining that a type or namespace cannot be found. If the component referred to is another project, Visual Studio.NET will infer dependency information from this and will use this information to work out the right order in which to build projects. (For example, if Project A has a reference to Project B, VS.NET will build Project B first, because it knows that Project A depends upon it.). Visual Studio.NET will copy the referenced component into the referencing project’s build directory if necessary. VS.NET will load the type information contained in the referenced components and use it to provide IntelliSense—the pop-up lists of statement completion suggestions.

(IntelliSense is described in more detail in the next chapter.) You can also browse the.

. Stepped-out, practical tutorials place programming concepts into a real-world context, making them more tangible for students. A wealth of exercises in each chapter offers students the chance to put the concepts they are learning to work. Clear code listings are easy for students to read and understand. A simple design and layout promotes learning without distracting from the content. Each chapter has a set of Short Answer questions and Workbench problems. Each new student edition comes with a Visual Basic ® 2010 Express software package.

Each new student edition comes with a Student Resource Disk that includes answers to select problems, source code, and data files for chapter tutorials. Instructor supplements include an Online Solutions Manual, PowerPoint ® Slides, Test Bank, Computerized Test Bank, WebCT, and Blackboard. VideoNotes VideoNotes are step-by-step video tutorials specifically designed to enhance the programming concepts presented in Gaddis, Starting Out with Visual Basic 2010, 5e. Students can view the entire problem-solving process outside of the classroom—when they need help the most. VideoNotes are available with the purchase of a new copy of select titles.

Go to www.pearsonhighered.com/videonotes for a brief VideoNotes demo. The book is completely updated for Visual Basic 2010 — This book is designed for use with Visual Basic 2010 and Visual Studio 2010.

The tutorials have been simplified — Many of the book’s tutorials have been simplified, and several of them have been completely replaced. These changes were made so students can work through the text at a quicker pace, and concentrate more on the important topics in each chapter. New VideoNotes to accompany many of the tutorials — This edition provides new VideoNotes for many of the book’s tutorials. The new VideoNotes explain the details of the code that the student writes and lead the student through the completion of the tutorials. Implicit line continuation is now used — In most situations where a statement continues across multiple lines, Visual Basic 2010 allows implicit line continuation. VB no longer requires the underscore character to be inserted to indicate a continued line. The programmer can simply press the Enter key where the underscore character was previously required.

In this book implicit line continuation is used, which helps to further simplify code. Message boxes introduced in Chapter 2 — In previous editions this book introduced message boxes in Chapter 3. In this edition message boxes are introduced as a simple way to display output in Chapter 2. Field-level input validation has been moved from Chapter 5 to Appendix A — In previous editions, Chapter 5 introduced field-level input validation using the CausesValidation property, the Validating event, and the Validated event. Because of the complexity of using this technique, many of the book's adopters prefer to use traditional input validation techniques instead. In this edition the authors have moved this material from Chapter 5 to Appendix A and use decision structures and standard exception handling for input validation. Class-Level Variables introduced in Chapter 3 — Class-level variables are now introduced in Chapter 2 along with local variables.

Random numbers introduced in Chapter 5 — In previous editions random numbers were introduced in Chapter 8 and only briefly covered. In this edition random numbers are introduced in Chapter 5 and used in more examples.

Appendix A has been enhanced and expanded as a reference — In this edition, Appendix A has been expanded as a reference for advanced user interface controls and programming techniques. The appendix now provides short examples demonstrating the following controls:. scroll bars. TabControls. WebBrowser controls. ErrorProvider components. DateTimePicker controls.

MonthCalendar controls. Appendix A also describes programming techniques for selecting text in a TextBox using the SelectionStart and SelectionLength properties and discusses field-level validation using the CausesValidation property, the Validating event, and the Validated event.

A section discussing user interface design guidelines also appears in this appendix. A new appendix on the Windows Presentation Framework (WPF) has been added — Appendix B is now an introduction to the Windows Presentation Framework (WPF).

This appendix includes a tutorial in which the student creates a simple WPF application. Visual Basic 2010 Express Edition — The book is bundled with Microsoft’s Visual Basic 2010 Express Edition–a streamlined product that captures the best elements of Visual Studio in an ideal format for learning programming. The Express edition offers an impressive set of tools for developing and debugging Visual Basic Windows Forms applications and Web applications, applications, including those that work with databases and use SQL. About the Author(s) Tony Gaddis is the principal author of the Starting Out with series of textbooks.

He has nearly two decades of experience teaching computer science courses, primarily at Haywood Community College. Tony is a highly acclaimed instructor who was previously selected as the North Carolina Community College Teacher of the Year, and has received the Teaching Excellence award from the National Institute for Staff and Organizational Development. The series includes introductory textbooks covering Programming Logic and Design, Alice, C, Java, Microsoft Visual Basic, and Python. Kip Irvine has written four computer programming textbooks, for Intel Assembly Language, C, Visual Basic, and COBOL. His Assembly Language for Intel-Based Computers has been translated to six languages, and has been a best seller since 1990. Kip grew up in Hawaii as a surfer, sailor, and surfboard maker.

He studied classical guitar and music composition at University of Hawaii, eventually earning his music doctorate from the University of Miami. He began programming computers for music synthesis around 1982, and taught at Miami-Dade Community College. He has a Masters degree in Computer Science from the University of Miami, and is currently on the computer science faculty at Florida International University.