大网数据广告活动
Windows 系统接口

Translating to Visual Basic

· 52CE 我爱测

You can add a COM object to your Visual Basic project either as a reference or a component. Once the object is added to your project, your application can access its classes and interfaces. You can then use the Visual Basic Object Browser to view the object's type library information in Visual Basic syntax.

You can add a COM object to your Visual Basic project either as a reference or a component. Once the object is added to your project, your application can access its classes and interfaces. You can then use the Visual Basic Object Browser to view the object's type library information in Visual Basic syntax.

Typically, controls are added to a project as a components and noncontrols are added as references. When a COM object is added as a component, it appears in the Visual Basic toolbox. New instances of that object are created by dragging the object icon from the toolbox onto a Visual Basic form or other type of container. New instances of COM objects added as references are created using the new keyword.

The distinction between using a class as a reference versus a component is subtle but important. When you add an object as a reference, you can use only the type library that the control provides, or the "raw" type library.

If you add a control as a component, Visual Basic merges the extender properties and methods of the form in which the control is embedded with the control's type library, thus providing a wrapped, extended version of the type library. With this version of the type library, you can use extender properties such as Top and Left as if they were part of the control, instead of the control's container.

Visual Basic does not currently support multiple type libraries built into a single .dll file. If you run into a DLL that incorporates multiple type libraries, you should get stand-alone copies of the type libraries from the source that supplied the object in order to use the object with Visual Basic.

For more information, see the following topics:

Related topics

Translating to C++

Translating to Java

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。