Creating ComponentsObjectivesIn this lesson, you will learn to:Create components for Windows FormsUse COM components in Vi...
Creating ComponentsComponentIs a reusable piece of code in a binary form that can beplugged into components from other ven...
Creating ComponentsJust a Minute…You need to write a program to validate user logins. Thisprogram will be used across appl...
Creating ComponentsComponent Architecture in .NETAssembly    Contains information about the files on which the     compone...
Creating ComponentsJust a Minute…Why does an assembly need a shared name?   ©NIIT                  Creating Components/Les...
Creating ComponentsComponent ClassesGet created when they follow defined standards ofinteraction provided by the IComponen...
Creating ComponentsJust a Minute…How will you use a component?   ©NIIT                   Creating Components/Lesson 13/Sli...
Creating ComponentsLife Cycle of a ComponentInitialization phase    Can be of two types:           ®Type initialization   ...
Creating ComponentsPolymorphismIs the ability of a class to implement functions with the same name to perform different ac...
Creating ComponentsCOM in .NET.NET supports COM and ActiveX objects for backwardcompatibility.Interaction between COM and ...
Creating ComponentsProblem Statement 13.D.1Customers of Diaz Telecommunications who place theirorders online must submit t...
Creating ComponentsTask ListIdentify the most suitable type of component.Identify the properties and methods for the compo...
Creating ComponentsTask 1: Identify the most suitable type of component.Result:A customized component has to be created to...
Creating ComponentsTask 2: Identify the properties and methods for thecomponent.You can have the following types of constr...
Creating ComponentsTask 2: Identify the properties and methods for thecomponent. (Contd.)Result:The two properties require...
Creating ComponentsTask 2: Identify the properties and methods for thecomponent. (Contd.)Result:RightChar(): A method to r...
Creating ComponentsTask 3: Create a project of the appropriate type.Task 4: Add properties and functions to thecomponent.T...
Creating ComponentsProblem Statement 13.P.1The Employee data in the call centers at DiazTelecommunications requires check ...
Creating ComponentsSummaryIn this lesson, you learned that:A component is a reusable piece of code in a binary form      t...
Upcoming SlideShare
Loading in...5
×

Vb net xp_13

227

Published on

Published in: Technology, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
227
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Vb net xp_13"

  1. 1. Creating ComponentsObjectivesIn this lesson, you will learn to:Create components for Windows FormsUse COM components in Visual Basic .NETImplement an Interface in Visual Basic .NET ©NIIT Creating Components/Lesson 13/Slide 1 of 19
  2. 2. Creating ComponentsComponentIs a reusable piece of code in a binary form that can beplugged into components from other vendors, with relatively little effort.Helps in reducing the development time.Helps in reducing errors because you reuse a code that is already tested. ©NIIT Creating Components/Lesson 13/Slide 2 of 19
  3. 3. Creating ComponentsJust a Minute…You need to write a program to validate user logins. Thisprogram will be used across applications. What will youdevelop the program as and why? ©NIIT Creating Components/Lesson 13/Slide 3 of 19
  4. 4. Creating ComponentsComponent Architecture in .NETAssembly Contains information about the files on which the component depends and the location of these files. Consists of a manifest and the portable executables (PE).Global Assembly Cache Is a repository of assemblies. Must have a unique identification to resolve name conflicts. To avoid this conflict you can also give a shared name to an assembly. ©NIIT Creating Components/Lesson 13/Slide 4 of 19
  5. 5. Creating ComponentsJust a Minute…Why does an assembly need a shared name? ©NIIT Creating Components/Lesson 13/Slide 5 of 19
  6. 6. Creating ComponentsComponent ClassesGet created when they follow defined standards ofinteraction provided by the IComponent interface.Can be created by using the .NET Class Library projecttemplate.Can be used in another project by adding a reference to the components. ©NIIT Creating Components/Lesson 13/Slide 6 of 19
  7. 7. Creating ComponentsJust a Minute…How will you use a component? ©NIIT Creating Components/Lesson 13/Slide 7 of 19
  8. 8. Creating ComponentsLife Cycle of a ComponentInitialization phase Can be of two types: ®Type initialization ®Instance initializationCleanup phase Is implemented by using the Dispose() method.Destroy phase Gets invoked when the garbage collector finds that there are no references to the component and therefore it calls the Finalize() method of the component. ©NIIT Creating Components/Lesson 13/Slide 8 of 19
  9. 9. Creating ComponentsPolymorphismIs the ability of a class to implement functions with the same name to perform different actions depending on how they are called.Is a feature supported by all object-oriented languages.Can be implemented in three ways: By implementing an interface By using inheritance By using abstract classes ©NIIT Creating Components/Lesson 13/Slide 9 of 19
  10. 10. Creating ComponentsCOM in .NET.NET supports COM and ActiveX objects for backwardcompatibility.Interaction between COM and .NET is provided through a wrapper called Runtime‑Callable Wrapper (RCW).A COM component can be called from .NET in the following ways: By converting the COM type library to a .NET assembly by using the tlbimp tool Using COM components directly by adding a reference ©NIIT Creating Components/Lesson 13/Slide 10 of 19
  11. 11. Creating ComponentsProblem Statement 13.D.1Customers of Diaz Telecommunications who place theirorders online must submit their credit card number, name, andthe expiry date of the credit card. The credit card numbersubmitted has to be validated. ©NIIT Creating Components/Lesson 13/Slide 11 of 19
  12. 12. Creating ComponentsTask ListIdentify the most suitable type of component.Identify the properties and methods for the component.Create a project of the appropriate type.Add properties and functions to the component.Build the component.Create a user interface to display the result.Verify the execution. ©NIIT Creating Components/Lesson 13/Slide 12 of 19
  13. 13. Creating ComponentsTask 1: Identify the most suitable type of component.Result:A customized component has to be created to verify thecredit card numbers supplied by the customers. ©NIIT Creating Components/Lesson 13/Slide 13 of 19
  14. 14. Creating ComponentsTask 2: Identify the properties and methods for thecomponent.You can have the following types of constructors in yourcomponent: Public Constructors — To enable developers to create instances of your component. Friend Constructors — To enable the usage of a component inside an assembly but not outside it. Private Constructors — To enable the usage only inside the component class. ©NIIT Creating Components/Lesson 13/Slide 14 of 19
  15. 15. Creating ComponentsTask 2: Identify the properties and methods for thecomponent. (Contd.)Result:The two properties required for the components are:  CustomerName: A property for the name of the customer of type string.  CardNumber: A property for the card number of type string.The following methods are required:  The default public constructor can be used for this component.  LeftChar(): A method to return the leftmost character from a string. ©NIIT Creating Components/Lesson 13/Slide 15 of 19
  16. 16. Creating ComponentsTask 2: Identify the properties and methods for thecomponent. (Contd.)Result:RightChar(): A method to return the rightmost character from a string.CharaceterToInt(): A method to return the numerical equivalent of a character.Validate(): A method to validate the card number. ©NIIT Creating Components/Lesson 13/Slide 16 of 19
  17. 17. Creating ComponentsTask 3: Create a project of the appropriate type.Task 4: Add properties and functions to thecomponent.Task 5: Build the component.Task 6: Create a user interface to display the result.Task 7: Verify the execution. ©NIIT Creating Components/Lesson 13/Slide 17 of 19
  18. 18. Creating ComponentsProblem Statement 13.P.1The Employee data in the call centers at DiazTelecommunications requires check for valid employee id,age, and salary entries. The employee id should start with theletter ‘E’ followed by three digits. The age should be from 21years to 60 years. In addition, the salary should be in therange of $3000 to $35000. Create a component that will checkthe validity of employee id, age, and salary. ©NIIT Creating Components/Lesson 13/Slide 18 of 19
  19. 19. Creating ComponentsSummaryIn this lesson, you learned that:A component is a reusable piece of code in a binary form that can be plugged into components from othervendors, with relatively little effort.An assembly contains information about the files on which the component depends and the location of these files.An interface can be implemented in a class to implement polymorphism.Component Object Module (COM) is alanguage‑independent software architecture that defines a setof standards for component interoperability.COM components can be used in .NET by using the tlbimp tool or by adding a reference. ©NIIT Creating Components/Lesson 13/Slide 19 of 19

×