The COM Course - Part 2--By Karl Moore
来源:互联网 发布:unity3d 开发数据库 编辑:程序博客网 时间:2024/04/30 08:54
> VBSquare.com
> VBAPI.com Home > ActiveX Development > Articles
Email this page | |
Printer Friendly | |
More From Karl | |
Post Feedback |
The COM Course - Part 3 |
The COM Course - Part 2 |
The COM Course - Part 1 |
ActiveX Control Tutorial - Part 5 |
ActiveX Control Tutorial - Part 4 |
VB.NET Uncovered: Big Changes |
VB.NET Uncovered: Working the Web |
Control the Panel |
Kill Context |
Learn to Program with Visual Basic 6 |
The COM Course - Part 2
By Karl Moore
Going It Alone
Remember how last week we threw a class into a standard Visual Basic project?
Well, one of the main points in the elegant COM philosophy is that code can be reused.
In other words, if you create an Accounting class in Visual Basic, you shouldn't only be able to access that from your application ?but perhaps also from another VB program your colleague is working on. And maybe an Excel spreadsheet that needs such data. You might even have a C++ programmer that needs to grab certain information for his latest project.
So what do you do? At the moment, you've worked with classes residing inside a standard Visual Basic application. And even if you give them a copy of your final .EXE program, they still won't be able to access the classes or properties within it.
The solution is to throw all the classes into a program of their own. Then they're "COM-enabled".
<Karl: Corr, I just invented that buzzword! COM-enabled. Let me call my trademark people...>
In other words, say your class has an AnnualProfitsToDate property. When this property is retrieved, your class dips into the company database, performs half-a-dozen calculations, then returns a value in pounds. Or dollars. Or Yen. Or green bananas. Or whatever.
Now instead of physically giving the Excel user a chunk of code to access the database, simply give him your 'class program'. This program 'exposes' your class and the AnnualProfitsToDate property, allowing other users to plug into its functionality. And instead of telling the C++ programmer how to manually perform the calculation so he can access the statistic himself, you could also give him this program, saving you both a lot of work.
So let's review this... in addition to throwing classes into Visual Basic projects, you can throw them into programs of their own, called ActiveX components, which say to other programs "Hey, I can do this ?provide an AnnualProfitsToDate property, update the Customers database, etc!".
And all the functionality of your ActiveX program can then be accessed from within any ActiveX-aware programming language. In other words, the AnnualProfitsToDate property can be retrieved from within Excel, C++, Access ?and more!
So how do you create an ActiveX program to hold your classes?
Introduction
Choices, Choices
Introduction - Going It Alone - Choices, Choices - Adding Properties and Methods - Testing your Class - Compiling your Program - Building your Test Program - Testing It All - Conclusion -
ActiveX | Beginning | Controls | Databases | Files | Graphics | Misc | Mouse | RegistryHome | Articles | Code | Projects | Books | Reviews | Discussion Forums
Tech News | Contact Us | Site Map | Join Newsletter | Link To UsCopyright ©1997-2001 Jelsoft Enterprises Limited. All rights reserved. Privacy Policy.
- The COM Course - Part 2--By Karl Moore
- The COM Course - Part 3--By Karl Moore
- The COM Course - Part 1--by karl moore
- Opening Doors: Notes On the Delphi ToolsAPI by its Creator - Part 2 - by Allen Bauer
- 【checkio】the Moore neighbourhood
- [Clojure] Data Collection and Data Analysis on the music of www.xiami.com - Part 2
- http://code4app.com/course
- Get data by SAFEARRAY** from COM(VB Code) in My VC COM Project (Code Part)
- SLAM Course - WS13/14 by Cyrill Stachniss (2) SLAM 概论
- Statistical Data Mining Tutorials by Andrew Moore
- Drupal 7 Line by Line : Part 2
- The principles of service-orientation part 2 of 6: Service contracts and loose coupling [by Thomas Erl]
- Business analysis and SOA part 2 of 6: Business service models and the entity-centric business service [by Thomas Erl]
- COM Interop Part 2: C# Server Tutorial
- About the course
- Of course the same
- Introduction to COM Part II - Behind the Scenes of a COM Server
- Sandbox Evasion with COM by Malware in-the-Wild
- 两个动态链接库(MFC扩展库)及其测试程序的例子(含源代码)
- 存储过程入门与提高
- JDBC2.0實現數據分頁
- Cracker初步:手动清除恶意网页代码
- The COM Course - Part 3--By Karl Moore
- The COM Course - Part 2--By Karl Moore
- The COM Course - Part 1--by karl moore
- 《Essential C++ 中文版》读书感悟--正确的观念重于一切
- 16-Bit Pixels (翻译)
- befriending a template in another namespace
- Herb Sutter 又要出新书--《Exceptional C++ Style》啦!
- 可输入的select
- 国际网页Web设计流程
- 各位帮帮我啊??学delphi5困扰!!