Objects from Visual Basic and Other Sources
The objects you use in Visual Basic 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 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 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 or Visual C#, can create and use assemblies. For more information, see Assemblies.
In the past, COM components were a traditional source of objects for Visual Basic programmers, but today .NET Framework assemblies are a better choice for new objects. You can still use existing COM components in your applications; however, COM objects must be accessed by means of .NET Framework 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. For more information, see COM Interop.
In addition to accessing native .NET Framework classes and COM classes, it is also possible to call functions defined in dynamic-link libraries (DLLs), such as those in the Win32 API. Visual Basic allows you to call functions in DLLs after they have been declared with a Declare statement. Visual Basic adds functionality to the Declare statement by allowing you to use the DllImportAttribute attribute to specify defaults for things such as CallingConvention, ExactSpelling, and SetLastError. Parameters for Declare statements can be annotated with the MarshalAsAttribute attribute, which supports conversion of parameters in ways that were not possible in earlier versions of Visual Basic.
See Also
Tasks
Walkthrough: Implementing Inheritance with COM Objects
How to: Set and Retrieve Properties
Concepts
Reference
Imports Statement (.NET Namespace and Type)
Integer Data Type (Visual Basic)
Double Data Type (Visual Basic)
String Data Type (Visual Basic)