Part 1 Getting Started with Visual Basic 2005 Express Edition In this section: Æ Chapter 1: Welcome to Visual Basic 2005 Express Edition Æ Chapter 2: Using Visual Basic 2005 Express Edition Æ Chapter 3: Introducing Windows Application Development Æ Chapter 4: Building Windows Forms 4398book.fm Page 1 Tuesday, February 14, 2006 1:53 PM COPYRIGHTED MATERIAL 4398book.fm Page 2 Tuesday, February 14, 2006 1:53 PM Chapter 1 Welcome to Visual Basic 2005 Express Edition Welcome to Mastering Visual Basic 2005 Express Edition ! We think that you 9ll find Visual Basic to be an easy-to-learn yet powerful programming language, and Visual Basic Express is an excellent tool for creating Windows applications. This book provides comprehensive instruction in both the Visual Basic Express development environment and the Visual Basic programming language itself.
In Part 1, we 9ll discuss how to get started creating applications with Visual Basic Express, we 9ll show the fundamentals of Windows application development, and finally we 9ll demonstrate how to create Windows forms. In Part 2, we 9ll discuss the Visual Basic programming language and describe how to create the functions, procedures, and events that will contain the bulk of your programming code. In addition, we 9ll also ... more. less.
discuss how to control the execution of your programs, how to use arrays and collections, and finally how to debug and handle errors within your application.<br><br> In Part 3, we 9ll discuss the Windows controls, which are the graphical building blocks of a Windows application. We 9ll start with some of the more basic controls and then move into the text controls. In addition, we 9ll also discuss the common Windows dialog boxes, the TreeView and ListView controls, and finally an assortment of other Windows controls that you might find useful.<br><br> In Part 4, we 9ll discuss the often-misunderstood concept of object-oriented programming. We 9ll start with a discussion of objects and how they are implemented, and then show you how to create your custom objects, including a custom Windows control. In Part 5, we 9ll discuss some of the more common programming tasks that you might need to do while creating applications with Visual Basic Express.<br><br> We 9ll demonstrate the new My object, discuss how to work with files and folders, and show how you can use Visual Basic Express to automate Microsoft Office applications. In addition, we 9ll also demonstrate some basic techniques for working with images, printing, characters, and strings; and we 9ll finish out the section with a discussion of how to create console applications. In Part 6, the final part of the book, we 9ll discuss how you can use Visual Basic Express to create applications that make use of a database, including how to create and manage databases using some built-in tools known as the Visual Database Tools.<br><br> We 9ll also show how you can use a data access technology known as ADO.NET to work with the data contained in a database and then provide an overview of SQL Server 2005 Express Edition, which is the database that comes with Visual Basic Express. Finally, we 9ll end the book with a discussion of how you can use Visual Basic Express to interact with the Internet. But enough about what 9s to come, let 9s get started!<br><br> Before we get into actually working with Visual Basic Express, we should first understand what it is, how it fits in with the other Visual Studio 2005 products, and what it can and can 9t do for you. 4398book.fm Page 3 Tuesday, February 14, 2006 1:53 PM 4 CHAPTER 1 WELCOME TO VISUAL BASIC 2005 EXPRESS EDITION What Is Visual Basic Express? Although Visual Basic Express is a new developer product offering from Microsoft, the Visual Basic language itself has been around for quite a long time.<br><br> In fact, it has its roots in what used to simply be called the BASIC programming language. TIP We won 9t go into the full history of Visual Basic, but to see an interesting timeline of how it came into being, check out http://addressof.com/blog/articles/VBTimeline.aspx . Microsoft first introduced Visual Basic back in May of 1991, and over the years has continued to enhance its capabilities, culminating with this year 9s release of Visual Basic 2005, which comes in a few different versions (one of which is, of course, Visual Basic 2005 Express Edition).<br><br> The idea behind this Express edition of Visual Basic is to provide an easy-to-use development envi- ronment that new developers or developers who are perhaps used to working with older versions of the language can use to get started with Visual Basic programming within the context of the ground-breaking .NET paradigm. After these developers get comfortable with programming in Visual Basic Express, the idea is that they can then move up into one of the more full-featured versions such as the Standard or Pro- fessional versions. But don 9t get lulled into thinking that Visual Basic Express is not a powerful programming tool; it is, and we think that techniques that we discuss throughout this book will demonstrate that.<br><br> Where the real difference lies between the Express and other editions is that there are some visual tools and project types that aren 9t available in the Express edition. For example, the Standard and Professional editions provide the capability to create Web forms using ASP.NET, whereas the Express edition does not. In addition, the more-advanced versions allow you to create applications for mobile devices such as Pocket PCs and Smartphones.<br><br> TIP To see a comparison of the features supported by the various Visual Basic 2005 editions, check out http://msdn2.microsoft.com/en-us/library/b4z62wxz(en-US,VS.80).aspx . In terms of visual tools, the Standard and Advanced versions include some visual designers such as the Web Forms Designer and the XML Schema Designer that are not found in Visual Basic Express. However, two of the most important visual tools, the Visual Database Tools and the Windows Forms Designer, are included with the Express edition.<br><br> As for the programming language itself, don 9t worry! Visual Basic Express packs the same punch as the other versions, including full access to the .NET Framework, which is the set of classes that all the Visual Studio programming languages use as their common programming platform. Other Express Editions In addition to Visual Basic Express, Microsoft has also released other Express products, some of which you may find useful as a Visual Basic programmer.<br><br> You can find all of these products online at http://msdn.microsoft.com/vstudio/express/default.aspx . Visual Web Developer 2005 Express Edition As we mentioned earlier, Visual Basic Express does not support creating Web applications with ASP.NET. However, this Express product does; in fact, it supports using the Visual Basic programming language to do so.<br><br> For more information, see Mastering Visual Web Developer 2005 Express Edition , by John Paul Mueller (Sybex, 2006). 4398book.fm Page 4 Tuesday, February 14, 2006 1:53 PM INSTALLING VISUAL BASIC EXPRESS 5 Visual C# 2005 Express Edition This Express product is similar to Visual Basic Express, except that it supports the C# programming language. Visual C++ 2005 Express Edition This Express product is similar to Visual Basic Express, except that it supports the C++ programming language.<br><br> Visual J# 2005 Express Edition This Express product is similar to Visual Basic Express, except that it supports the J# programming language, which is Microsoft 9s version of the Java program- ming language. SQL Server 2005 Express Edition This Express product is the clight d version of SQL Server 2005, which is Microsoft 9s flagship database product, and it is definitely something that you will want to work with. In fact, as you 9ll see in the next section, when you install Visual Basic Express you are given the option to also install SQL Server Express, which you 9ll definitely want to do to follow along with many of the examples in this book.<br><br> We 9ll talk about SQL Server Express in detail in Part 6. For more information, see Mastering SQL Server 2005 Express Edition , by Mike Gunderloy and Susan Sales Harkins (Sybex, 2006). Installing Visual Basic Express Installing Visual Basic Express is a simple and relatively painless process, and there are two ways to do it: install it from the Microsoft Web site or install it from a CD.<br><br> In the sections that follow, we 9ll show you how to install it from the Microsoft Web site, but if you install it from a CD, the process will be basically the same (except for the download part). NOTE Microsoft has graciously allowed us to include one copy each of Visual Basic Express and SQL Server Express with this book, and we recommend that you install both from the CD because install- ing them from the Internet is quite time-consuming. 1.<br><br> The first step of installing Visual Basic Express from the Microsoft Web site is to go to http:// msdn.microsoft.com/vstudio/express/vb/download/ and click the Download link. NOTE At the time of the writing of this book, Microsoft was allowing customers to download Visual Basic Express free, provided that they register the product. You 9ll need to do that to get the registra- tion key to activate Visual Basic Express if you download the product from the Internet.<br><br> 2. After clicking the Download link, a dialog box will appear, asking you whether you want to save the vbsetup.exe file locally or simply run it now. Either option is fine and up to you; just remember that if you choose to save it to your hard drive, you 9ll need to open it later to con- tinue the installation process.<br><br> 3. After the vbsetup.exe file is downloaded, you might be prompted to run it; click Run to go ahead and allow the file to execute. 4.<br><br> The first screen that you will see is the Welcome To Setup screen, as shown in Figure 1.1. In this screen, you can optionally choose whether or not to send Microsoft information about your setup experience, which is totally up to you. Click Next to move to the next screen.<br><br> 4398book.fm Page 5 Tuesday, February 14, 2006 1:53 PM 6 CHAPTER 1 WELCOME TO VISUAL BASIC 2005 EXPRESS EDITION Figure 1.1 Welcome To Setup screen 5. The next screen you see is the End User License Agreement screen, as shown in Figure 1.2. In this screen, you 9re presented with the license agreement, and you must click the I Accept The Terms Of The License Agreement check box before you can continue to the next screen.<br><br> Once you 9ve read the license agreement, click the check box and then click Next. 6. The next screen you see is the Installation Options screen as shown in Figure 1.3.<br><br> In this screen, you 9re presented with two additional components that you can install along with Visual Basic Express. One is the Microsoft MSDN 2005 Express Edition, which is the help system for Visual Basic Express; the other is Microsoft SQL Server 2005 Express Edition. We recommend that you install both of these so click the check box next to each option, and then click Next.<br><br> Figure 1.2 End User License Agreement screen 4398book.fm Page 6 Tuesday, February 14, 2006 1:53 PM INSTALLING VISUAL BASIC EXPRESS 7 Figure 1.3 Installation Options screen 7. The next screen is the Destination Folder screen, as shown in Figure 1.4. In this screen, you 9re asked to specify the folder in which Visual Basic Express will be installed and prompted with a default location.<br><br> We recommend that you not change the folder name just to keep things simple. Notice in this screen the list of components that will be installed. In addition to Visual Basic Express and the two options you selected in the previous screen, the Microsoft .NET Framework 2.0 will also be installed.<br><br> Also notice the disk space that the installation of all these components will take: a whopping 1.8 gigabytes! Click the Install button to proceed to the next screen. 8.<br><br> At this point the actual installation starts, and the setup routine will display the Download and Install Progress screen as shown in Figure 1.5. This may take some time depending on whether you are installing from the Web or the CD. Figure 1.4 Destination Folder screen 4398book.fm Page 7 Tuesday, February 14, 2006 1:53 PM 8 CHAPTER 1 WELCOME TO VISUAL BASIC 2005 EXPRESS EDITION Figure 1.5 Download and Install Progress screen 9.<br><br> Once the download and installation is complete, the next screen that you will see is the Setup Complete screen, as shown in Figure 1.6. In this screen, you 9re advised to visit the Windows Update Web site to check for any updates, and you 9re given the opportunity to go ahead and register the product. Note that you don 9t have to register at this point; you can do it later if you wish.<br><br> Click Exit to end the installation. That 9s it! Visual Basic Express and its supporting and optional components are now installed and ready for use.<br><br> Note that the first time you actually launch Visual Basic Express, you 9ll see a message box like the one shown in Figure 1.7. Don 9t be alarmed at this. All that 9s happening here is that Visual Basic Express is making a few final configurations before it is used for the first time.<br><br> You won 9t see this box again after the first use. Figure 1.6 Setup Complete screen 4398book.fm Page 8 Tuesday, February 14, 2006 1:53 PM SUMMARY 9 Figure 1.7 Final configuration for Visual Basic Express Summary In this chapter, we reviewed the major parts of this book and what they 9ll cover, provided a brief over- view of Visual Basic Express and how it fits in with the other Express edition products, and walked you through installing Visual Basic Express. In the next chapter, we 9ll open up Visual Basic Express and start exploring its features, including the integrated development environment (IDE) that it provides.<br><br> In addition, we 9ll show you how easy it is to quickly create your first Windows application. 4398book.fm Page 9 Tuesday, February 14, 2006 1:53 PM 4398book.fm Page 10 Tuesday, February 14, 2006 1:53 PM