"Anthony Jones" wrote:
[the unary + operator] is quite an efficient means of converting although a bit obscure.
Ah, well now HERE *I* get to be the pedantic one and point you to my other
post.
Unary + is no more efficient (and possibly a few nanoseconds less efficient)
than using CINT( ) or CLNG( ).
In both cases, the byte code produced by the compiler is going to be
something like
Push literal string "EMPLYERUSERS"
Push builtin object (Session object, that is)
Invoke COM method [which leaves the result on top of stack]
Invoke Unary plus operator
or
Push literal string "EMPLYERUSERS"
Push builtin object (Session object, that is)
Invoke COM method [which leaves the Variant result on top of stack]
Invoke CINT/CLNG build in function
[Don't quote me on this...it's been 7 years since I messed around with the
internals of the VBS code.]
And, as I noted, CINT/CLNG and the unary plus operator will all have to
invoke the COM function VariantChangeTypeEx( ) to convert the
whatever-it-is-variant to a numeric datatype. But then the difference is
that unary + will ask to convert the variant to a vt_Double and CINT/CLNG
will ask to convert it to vt_Int, and that latter conversion is very very
marginally faster.
Since the VBS runtime uses 60 to 100 lines of C++ code to execute each byte
code token, all the surrounding stuff will take so much time in relation to
the VariantChangeTypeEx call that you'll never be able to time or see the
difference. But it's there. <grin/>