Introduction Sometimes you'll see code in a mixture of styles, such as: objVar =Me CType( Form). Text ="New Dialog Title Text The code with a white background is code we ve already looked at and that we don t wish to examine further Advice, hints, and background information come in an italicized, indented paragraph like this Important pieces of information come in shaded boxes like this. Customer Support We always value hearing from our readers, and we want to know what you think about this book: what you liked, what you didnt like, and what you think we can do better next time. You can send us your comments, either by returning the reply card in the back of the book or by email to feedbackewrox com Please be sure to mention the book title in your message How to Download the Sample Code for the Book WhenyouvisittheWroxsitewww.wrox.comsimplylocatethetitlethroughourSearchfacilityorby using one of the title lists. Click Download in the Code column or click Download Code on the books detail page The files that are available for download from our site have been archived using WinZip. When you have saved the attachments to a folder on your hard drive, you need to extract the files using a decompression program such as Win Zip or PKUnzip. When you extract the files, the code is usually extracted into chap- ter folders. When you start the extraction process, ensure that your software(WinZip, PKUnzip, and so on) is set to use folder names. Errata We've made every effort to make sure that there are no errors in the text or in the code. However, no one is perfect and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or a faulty piece of code, we would be very grateful for feedback. By sending in errata, you may save anothe reader hours of frustration, and of course, you will be helping us provide even higher quality informa tion Simply email the information to support wrox. com; your information will be checked and if cor- rect, posted to the errata page for that title, or used in subsequent editions of the book TofinderrataontheWebsitegotowww.wroxcomandsimplylocatethetitlethroughourAdvanced Search or title list. Click the Book Errata link, which is below the cover graphic on the book's detail page XXX
xxx Introduction Sometimes you’ll see code in a mixture of styles, such as: Dim objVar as Object objVar = Me CType(objVar, Form).Text = “New Dialog Title Text” The code with a white background is code we’ve already looked at and that we don’t wish to examine further. Advice, hints, and background information come in an italicized, indented paragraph like this. Customer Support We always value hearing from our readers, and we want to know what you think about this book: what you liked, what you didn’t like, and what you think we can do better next time. You can send us your comments, either by returning the reply card in the back of the book or by email to feedback@wrox.com. Please be sure to mention the book title in your message. How to Download the Sample Code for the Book When you visit the Wrox site, www.wrox.com, simply locate the title through our Search facility or by using one of the title lists. Click Download in the Code column or click Download Code on the book’s detail page. The files that are available for download from our site have been archived using WinZip. When you have saved the attachments to a folder on your hard drive, you need to extract the files using a decompression program such as WinZip or PKUnzip. When you extract the files, the code is usually extracted into chapter folders. When you start the extraction process, ensure that your software (WinZip, PKUnzip, and so on) is set to use folder names. Errata We’ve made every effort to make sure that there are no errors in the text or in the code. However, no one is perfect and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or a faulty piece of code, we would be very grateful for feedback. By sending in errata, you may save another reader hours of frustration, and of course, you will be helping us provide even higher quality information. Simply email the information to support@wrox.com; your information will be checked and if correct, posted to the errata page for that title, or used in subsequent editions of the book. To find errata on the Web site, go to www.wrox.com, and simply locate the title through our Advanced Search or title list. Click the Book Errata link, which is below the cover graphic on the book’s detail page. Important pieces of information come in shaded boxes like this. 03_575368 flast.qxd 10/7/05 10:46 PM Page xxx
Introduction p2p wrox. com For author and peer discussion, join the P2P mailing lists. Our unique system provides programmer to programmer(tm)contact on mailing lists, forums, and newsgroups, all in addition to our one-to-one email support system. If you post a query to P2P, you can be confident that the many Wrox authors and other industry experts who are present on our mailing lists are examining it. At p2p wrox. com you will find a number of different lists that will help you, not only while you read this book, but also as you develop your own applic Particularly appropriate to this book are the vb_dotnet and pro_vb_dotnet lists. To subscribe to a mailing list just follow these steps 1.gotohttp://p2p.wrox.com/ 2. Choose the appropriate category from the left menu bar 3. Click the mailing list you wish to join 4. Follow the instructions to subscribe and fill in your email address and password 5. Reply to the confirmation email you receive 6. Use the subscription manager to join more lists and set your email preferences You can read messages in the forums without joining P2P, but in order to post your own messages, you must 10in Once you join, you can post new messages and respond to messages other users post. You can read mes- sages at any time on the Web. If you would like to have new messages from a particular forum emailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to ques- tions about how the forum software works as well as many common questions specific to P2P and Wrox books To read the FAQs, click the FAQ link on any P2P page
xxxi Introduction p2p.wrox.com For author and peer discussion, join the P2P mailing lists. Our unique system provides programmer to programmer(tm) contact on mailing lists, forums, and newsgroups, all in addition to our one-to-one email support system. If you post a query to P2P, you can be confident that the many Wrox authors and other industry experts who are present on our mailing lists are examining it. At p2p.wrox.com you will find a number of different lists that will help you, not only while you read this book, but also as you develop your own applications. To subscribe to a mailing list just follow these steps: 1. Go to http://p2p.wrox.com/. 2. Choose the appropriate category from the left menu bar. 3. Click the mailing list you wish to join. 4. Follow the instructions to subscribe and fill in your email address and password. 5. Reply to the confirmation email you receive. 6. Use the subscription manager to join more lists and set your email preferences. You can read messages in the forums without joining P2P, but in order to post your own messages, you must join. Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum emailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing. For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page. Particularly appropriate to this book are the vb_dotnet and pro_vb_dotnet lists. 03_575368 flast.qxd 10/7/05 10:46 PM Page xxxi
03_575368 flast.qxd 10/7/05 10:46 PM Page xxxii
What s microsoft net? New technologies force change, nowhere more so than in computers and software. Occasionally new technology is so innovative that it forces us to challenge our most fundamental assumptions In the computing industry, the latest such technology is the Internet. It has forced us to rethink However, that process takes time. Usually, when a powerful new technology comes along, it is first simply strapped onto existing platforms. So it has been for the Internet. Before the advent of Microsoft. NET, developers used older platforms with new Internet capabilities"strapped on The resulting systems worked, but they were expensive and difficult to produce, hard to use, and difficult to maintain Realizing this several years ago, Microsoft decided it was time to design a new platform from the ground up specifically for the post-Internet world. The result is called NET. It represents a turning point in the world of Windows software for Microsoft platforms. Microsoft has staked their future on NET and publicly stated that henceforth almost all their research and development will be done on this platform. It is expected that, eventually, almost all Microsoft products will be ported to the. NET platform. ( However, the name"NET"will evolve, as you will see at the end of the chapter Microsoft is now at version 2.0 of Microsoft. NET, and the development environment associated with this version is called Visual Studio 2005. The version of Visual Basic in this version is, thus called Visual Basic 2005, and that's what this book is all about What s∴NET? Microsofts. NET initiative is broad-based and very ambitious. It includes the NET Framework which encompasses the languages and execution platform, plus extensive class libraries, provid- ing rich built-in functionality. Besides the core NET Framework, the NET initiative includes pro- tocols(such as the Simple Object Access Protocol, commonly known as SOAP)to provide a new level of software integration over the Internet, via a standard known as Web Service
What Is Microsoft .NET? New technologies force change, nowhere more so than in computers and software. Occasionally, a new technology is so innovative that it forces us to challenge our most fundamental assumptions. In the computing industry, the latest such technology is the Internet. It has forced us to rethink how software should be created, deployed, and used. However, that process takes time. Usually, when a powerful new technology comes along, it is first simply strapped onto existing platforms. So it has been for the Internet. Before the advent of Microsoft .NET, developers used older platforms with new Internet capabilities “strapped on.” The resulting systems worked, but they were expensive and difficult to produce, hard to use, and difficult to maintain. Realizing this several years ago, Microsoft decided it was time to design a new platform from the ground up specifically for the post-Internet world. The result is called .NET. It represents a turning point in the world of Windows software for Microsoft platforms. Microsoft has staked their future on .NET and publicly stated that henceforth almost all their research and development will be done on this platform. It is expected that, eventually, almost all Microsoft products will be ported to the .NET platform. (However, the name “.NET” will evolve, as you will see at the end of the chapter.) Microsoft is now at version 2.0 of Microsoft .NET, and the development environment associated with this version is called Visual Studio 2005. The version of Visual Basic in this version is, thus, called Visual Basic 2005, and that’s what this book is all about. What Is .NET? Microsoft’s .NET initiative is broad-based and very ambitious. It includes the .NET Framework, which encompasses the languages and execution platform, plus extensive class libraries, providing rich built-in functionality. Besides the core .NET Framework, the .NET initiative includes protocols (such as the Simple Object Access Protocol, commonly known as SOAP) to provide a new level of software integration over the Internet, via a standard known as Web Services. 04_575368 ch01.qxd 10/7/05 10:50 PM Page 1
Chapter 1 Although Web Services are important (and are discussed in detail in Chapter 23), the foundation of all NET-based systems is the NET Framework. This chapter will look at the NET Framework from the viewpoint of a Visual Basic developer. Unless you are quite familiar with the Framework already, you should consider this introduction an essential first step in assimilating the information about visua Basic Net that will be presented in the rest of this book The first released product based on the. NET Framework was Visual Studio. NET 2002, which was pub- licly launched in February 2002, and included version 1.0 of the. NET Framework. Visual Studio NET 2003 was introduced a year later and included version 1.1 of the. NET Framework. As mentioned, the current version is Visual Studio 2005. (Note that the"NET"part of the name has been dropped for this This book assumes that you are using VS NET 2005. Some of the examples will work transparently with VS NET 2002 and VSNET 2003, but you should not count on this, because the difference between 2.0 A Broad and deep platform for the Future Framework a platform doesn't begin to describe how broad and deep it is. It encom- passes a virtual machine that abstracts away much of the windows API from development. It includes a class library with more functionality than any yet created. It makes available a development environ- ment that spans multiple languages, and it exposes an architecture that makes multiple language inte- gration simple and straightforward At first glance, some aspects of NET appear similar to previous architectures, such as UCSD Pascal and Java. No doubt some of the ideas for. NET were inspired by these past efforts, but there are also many brand new architectural ideas in NET. Overall, the result is a radically new approach to software The vision of Microsoft NET is globally distributed systems, using XML as the universal glue to allow functions running on different computers across an organization or across the world to come together in a single application. In this vision, systems from servers to wireless palmtops, with everything in etween, will share the same general platform, with versions of NET available for all of them, and with each of them able to integrate transparently with the others This does not leave out classic applications as you have always known them, though. Microsoft. NET also aims to make traditional business applications much easier to develop and deploy. Some of the tech- nologies of the NET Framework, such as Windows Forms, demonstrate that Microsoft has not forgotten the traditional business developer. In fact, such developers will find it possible to Internet-enable thei plications more easily than with any previous platform. What's wrong with DNA and COM? The pre- NET technologies used for development on Microsoft platforms encompassed the COM Component Object Model)standard for creation of components, and the DNA model for multitier soft- ware architectures. As these technologies were extended into larger, more enterprise-level settings, and as integration with the Internet began to be important, several major drawbacks became apparent. These
Although Web Services are important (and are discussed in detail in Chapter 23), the foundation of all .NET-based systems is the .NET Framework. This chapter will look at the .NET Framework from the viewpoint of a Visual Basic developer. Unless you are quite familiar with the Framework already, you should consider this introduction an essential first step in assimilating the information about Visual Basic .NET that will be presented in the rest of this book. The first released product based on the .NET Framework was Visual Studio .NET 2002, which was publicly launched in February 2002, and included version 1.0 of the .NET Framework. Visual Studio .NET 2003 was introduced a year later and included version 1.1 of the .NET Framework. As mentioned, the current version is Visual Studio 2005. (Note that the “.NET” part of the name has been dropped for this version.) This book assumes that you are using VS.NET 2005. Some of the examples will work transparently with VS.NET 2002 and VS.NET 2003, but you should not count on this, because the difference between 2.0 and the earlier versions is significant. A Broad and Deep Platform for the Future Calling the .NET Framework a platform doesn’t begin to describe how broad and deep it is. It encompasses a virtual machine that abstracts away much of the Windows API from development. It includes a class library with more functionality than any yet created. It makes available a development environment that spans multiple languages, and it exposes an architecture that makes multiple language integration simple and straightforward. At first glance, some aspects of .NET appear similar to previous architectures, such as UCSD Pascal and Java. No doubt some of the ideas for .NET were inspired by these past efforts, but there are also many brand new architectural ideas in .NET. Overall, the result is a radically new approach to software development. The vision of Microsoft .NET is globally distributed systems, using XML as the universal glue to allow functions running on different computers across an organization or across the world to come together in a single application. In this vision, systems from servers to wireless palmtops, with everything in between, will share the same general platform, with versions of .NET available for all of them, and with each of them able to integrate transparently with the others. This does not leave out classic applications as you have always known them, though. Microsoft .NET also aims to make traditional business applications much easier to develop and deploy. Some of the technologies of the .NET Framework, such as Windows Forms, demonstrate that Microsoft has not forgotten the traditional business developer. In fact, such developers will find it possible to Internet- enable their applications more easily than with any previous platform. What’s Wrong with DNA and COM? The pre-.NET technologies used for development on Microsoft platforms encompassed the COM (Component Object Model) standard for creation of components, and the DNA model for multitier software architectures. As these technologies were extended into larger, more enterprise-level settings, and as integration with the Internet began to be important, several major drawbacks became apparent. These included: 2 Chapter 1 04_575368 ch01.qxd 10/7/05 10:50 PM Page 2