The COM Course - Part 2--By Karl Moore

原创 2002年03月20日 09:07:00
top_left.gif
Search VB-World:         
home_off.gifarticles_on.gifcode_off.gifprojects_off.gifbooks_off.gifreviews_off.gifdiscuss_off.gif > VBForums.com
> VBSquare.com
> VBAPI.com
top_right.gif
clear.gif
clear.gif
  Home  > ActiveX Development > Articles
clear.gif
clear.gif
clear.gif
clear.gif
clear.gif
clear.gif
clear.gif
clear.gif
email_button.gif Email this page
print_button.gif Printer Friendly
more_button.gif More From Karl
feedback_button.gif Post Feedback

Related
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

Hot Picks
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?

prev.gifIntroduction

Choices, Choices next.gif

clear.gif
clear.gif
  In This Article
clear.gif
clear.gif
clear.gif

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 | Registry
Home | Articles | Code | Projects | Books | Reviews | Discussion Forums
Tech News | Contact Us | Site Map | Join Newsletter | Link To Us
clear.gif
bot_left.gif
Copyright ©1997-2001 Jelsoft Enterprises Limited. All rights reserved. Privacy Policy.
bot_right.gif

Android开发笔记(八十五)手机数据库Realm

Realm应用背景 Android自带的SQLite数据库,在多数场合能够满足我们的需求,但随着app广泛使用,SQLite也暴露了几个不足之处: 1、开发者编码比较麻烦,而且还要求开发者具备SQL语...
  • aqi00
  • aqi00
  • 2016年04月13日 17:13
  • 6643

多数投票算法(Boyer-Moore Algorithm)详解

多数投票算法(Boyer-Moore Algorithm)详解
  • kimixuchen
  • kimixuchen
  • 2016年10月11日 19:08
  • 2009

AndroidStudio报错处理心得

关于在AS上用svn处理集成,步骤网上有很简单百度一下。我在下载安装svn后,在studio中进行配置,配置是否成功需要经过验证,怎么验证,具体步骤如下: 1.首先验证你的svn是否安装成功,通过桌...
  • Leizi030017
  • Leizi030017
  • 2016年10月25日 18:41
  • 1325

a first course in probability 概率论基础教程 英文第5版 PDF格式 (part2 )

  • 2010年02月10日 13:15
  • 14MB
  • 下载

Step-by-Step SqlAlchemy Tutorial(part 1 of 2)

一直觉得orm很高深,今天时间比较充分打算学习下 安装说一点,我的系统是win7 64位家庭普通版 用easy_install安装sqlalchemy出现问题,于是下载最新版0.7.6的zip压缩...
  • yueguanghaidao
  • yueguanghaidao
  • 2012年04月22日 01:35
  • 4048

tomcat启动时报Caused by: java.lang.ClassNotFoundException: com.opensymphony.xwork2.ActionSupport

报错信息: 严重: Exception sending context initialized event to listener instance of class org.springframew...
  • Peditable
  • Peditable
  • 2011年08月04日 14:47
  • 22953

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 没有为参数号 2 设置值

1、错误描述org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized S...
  • you23hai45
  • you23hai45
  • 2017年03月25日 12:49
  • 1981

jndi step by step(2)(转http://www.cnblogs.com/aurawing/articles/1887036.html)

jndi step by step(2)(4) 目录服务操作 1、目录服务的操作    我们会用LDAP作为例子来讲解目录服务的操作。与命名服务不同,目录服务的内容上下文的初始化方式需要    改变:...
  • fjfdszj
  • fjfdszj
  • 2011年03月01日 10:46
  • 625

Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar

信息: No Spring WebApplicationInitializer types detected on classpath 08:56:31,833 ERROR Dispatcher:3...
  • u011422744
  • u011422744
  • 2014年10月07日 09:04
  • 3700

Caused by: java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector

六月 22, 2017 5:04:08 下午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationI...
  • kzadmxz
  • kzadmxz
  • 2017年06月22日 17:11
  • 894
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:The COM Course - Part 2--By Karl Moore
举报原因:
原因补充:

(最多只允许输入30个字)