This documentation is archived and is not being maintained.

Objects from Visual Basic and Other Sources

The objects you use in Visual Basic .NET come from both internal and external sources. Examples of internal objects include intrinsic objects and classes in your project; examples of external objects include assemblies and COM objects.

Internal Objects

Intrinsic (or built-in) objects are objects that Visual Basic .NET natively provides. These include the primitive scalar types such as Integer and Double as well as the Array and String types. You do not need to create references to internal objects before using them in your project.

Other internal objects are instances of classes in your current project. You can use these classes wherever necessary within your project, and you can make them available for use by other applications when you create an assembly.

External Objects

External objects are those that come from other projects or assemblies that are not available to your project by default. You must create project references to external objects before using them in your project.

Assemblies are the most common source of objects for Visual Basic .NET applications. The .NET Framework includes assemblies that contain commonly used objects. Some objects in the .NET Framework are treated as intrinsic objects, but most assemblies must be explicitly imported using the Imports statement before they can be used. Any language compliant with the Common Language Specification (CLS), such as Visual Basic .NET or Visual C#, can create and use assemblies. For details, see Assemblies.

In the past, COM components were a traditional source of objects for Visual Basic programmers, but today .NET assemblies are a better choice for new objects. You can still use existing COM components in your applications; however, COM objects must be accessed via .NET interoperability classes. Accessing a COM library requires the use of an interoperability assembly containing interoperability classes for each COM class defined within the COM library.

In addition to accessing native .NET classes and COM classes, it is also possible to call functions defined in dynamic-link libraries (DLL's). Visual Basic .NET allows you to call functions in DLL's after they have been declared with a Declare statement. Visual Basic .NET adds functionality to the Declare statement by allowing you use the DllImport attribute to specify defaults for things such as CallingConvention, ExactSpelling, and SetLastError. Parameters for Declare statements can be annotated with the MarshalAs attribute, which supports conversion of parameters in ways that were not possible in earlier versions of Visual Basic.

See Also

The Basics of Working with Objects | Relation of Objects to Each Other | Walkthrough: Implementing Inheritance with COM Objects | Setting and Retrieving Properties | Creating and Using Objects | Declare Statement | Imports Statement | DllImportAttribute Class | Integer Data Type | Double Data Type | String Data Type | MarshalAsAttribute Class