XLL+ Class Library

CXlOper::Ret

Prepares a CXlOper to be returned as a value to Excel

[C++]
LPXLOPER Ret();

Return value

This function returns a pointer to some static memory containing a copy of this CXlOper.

Remarks

The Ret() function is essential to the implementation of the memory management features of the library. When you return data to Excel from an add-in function, the data must be contained in memory which remains in scope even when the function goes out of scope.

The Ret() function takes the current value in the CXlOper and copies it into heap memory. It then releases the memory of the original copy and sets flags in the new copy so that Excel will properly manage the memory clean-up on your behalf.

Once you have called Ret(), a CXlOper is no longer valid, and cannot be used for any purpose.

Ret() is only used in the return statements of add-in functions, for example:

CXlOper xloResult;
xloResult = 123.456;
return xloResult.Ret();

Example

MySqrt Example

Requirements

Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlOper::RetError() | CXlOper::RetString()