Well... we don't really use CObj anymore... more of a VB6 thing than
anything.
Second of all, it is good practice for explicit type casting, which if you
had Option Strict On you would get errors if you didn't use CObj in this
case.
or the more preferred VB.NET Style
CType(myDoubleVariable, System.Object)
or
DirectCast(myDoubleVar, System.Object)
"Raterus" <raterus@localhost> wrote in message
news:u4nCaA%23%(E-Mail Removed)...
> I'm trying to figure out what exactly the CObj() function does. I'm not
> using it for any reason, but on a review of all those casting functions
like
> cstr, cbool, cdate, I saw it, but couldn't for the life of me figure out
the
> point of such a function, or how I would ever need to use it. It takes in
> an object as a parameter, and returns an object.
>
> Here's what the MSDN documentation has to say about it:
>
> CObj Example
>
> This example uses the CObj function to convert a numeric value to Object.
> The Object variable itself contains only a four-byte pointer, which points
> to the Double value assigned to it.
>
> Dim MyDouble As Double
> Dim MyObject As Object
> MyDouble = 2.7182818284
> MyObject = CObj(MyDouble) ' Double value is pointed to by MyObject.
>
> Just wondering...
> --Michael
>
>
|