VB.NET Language in a Nutshell

   
CObj Function

Named Arguments

No

Syntax

CObj( expression )

expression (required; any)

Return Value

expression cast as an Object data type

Description

Converts any expression that can be interpreted as an object to Object

Rules at a Glance

expression can be any data type, including a strongly typed object, as the following code fragment illustrates:

Dim oSomeClass As New CSomeClass Dim oObj As Object oObj = CObj(oSomeClass)

Example

The following code:

Dim obj As Object obj = CObj("test")

casts the string "test" to type Object and places it in the Object variable obj .

Programming Tips and Gotchas

VB.NET/VB 6 Differences

The CObj function is new to VB.NET. The closest equivalent in VB 6 is CVar , which converts a data type to a Variant.

   

Категории