Re: Print a return value without storing it (also IIF and ternary operator)




<cjg.groups@xxxxxxxxx> wrote
A bit later, I used Format() function within a Print function without
storing anything and it worked. Something like:

Print "some text" & Format(OrderDate, "mm/dd/yyyy")

You appear to be over thinking the issue. Every function returns a
stored value as indicated in the help files. In this case the returned
data type from Format is a Variant (string). Whether you choose
to assign it to a local variable (or not) is up to you.


Both Format and IIF are functions, but returned by value while the
other returned by reference. True?

The method used is transparent, why would you care? In fact,
because you concatentate a string in the call to Print, VB must
first do the concatenation, store that new value, and pass the
new value on to the Print method. You need not store the results
of the concatenation yourself, VB will handle that transparently,
just as it does for returned values from functions.

How can I tell from the VB (with
Access 2003) help files if a function can be used inside another
function like this?

I don't think you'll find a function (or create a function) that cannot
be used in this manner. The returned data type for VB functions are
usually listed at the start of the help file description. As long as your
code follows the type-checking and/or syntax rules, VB will manage
storing the values as needed. One of the well know side-effects of
that 'transparency' is when VB attempts to convert between data
types, without being told to do so. (re: Evil Type Conversion)
But that is another issue. If you are having problems using functions
within the call to other functions, post that code to get help on that
specific issue....

HTH
LFS


.



Relevant Pages