Chapter 9. Creating Code Components

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); } function Print() { window.focus(); if(window.print) { window.print(); window.setTimeout('window.close();',5000); } }
Team-Fly    

Special Edition Using Microsoft® Visual Basic® .NET
By Brian Siler, Jeff Spotts
Table of Contents
Part II:  Visual Basic Programming Fundamentals


In this chapter

Understanding Classes

Building a Class

Using a New Class in an Application

Using Remoting to Work with Distributed Objects

From Here…

As you develop more (and better) applications, you will find many opportunities to reuse code that you have already written. You may be tempted to copy code from old projects and paste it into your new projects. You would quickly learn, however, that doing so has several drawbacks. One of the chief drawbacks of this technique is the need to manage multiple copies of the same code. If you have developed a procedure that solves a certain problem, and you copy and paste that procedure into multiple projects, what happens if you discover a bug in the procedure? You must locate each project that uses that procedure, make the appropriate changes, and recompile each application.

A much better way is to create a code component, which is essentially a custom class that contains procedures and functions that can be used by multiple applications. This approach allows you to incorporate object-oriented programming (OOP) techniques into your applications, making them reusable and portable.

Note

Technically, there is a difference between a code component and a simple class. A code component starts out as a class; it becomes a component when it conforms to a standard for component interaction, which is provided by the IComponent interface. This interface ensures that components utilize .NET's Common Language Specification (CLS), which is the backbone for components authored in any of the .NET languages and includes basic language features needed by many applications. In essence, you can create components using any of the .NET languages and incorporate them into the .NET framework; in turn, they can be used by any other .NET language, regardless of their origin.


Object-oriented programming techniques are useful because they allow you to reuse your code efficiently. This chapter discusses how to create classes in Visual Basic .NET. Classes allow you to create objects and take advantage of object-oriented programming techniques in Visual Basic. When working on a large project, for example, each team member can create a specific class and make it available for others to use.


    Team-Fly    
    Top
     



    Special Edition Using Visual Basic. NET
    Special Edition Using Visual Basic.NET
    ISBN: 078972572X
    EAN: 2147483647
    Year: 2001
    Pages: 198

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net