XLL+ Class Library

MySqrt Example

This example shows how to optionally return an error.

// Function:    MySqrt
// Returns:     LPXLOPER
// Description: Returns the square root of the input

//{{XLP_SRC(MySqrt)
    // NOTE - the FunctionWizard will add and remove mapping code here.
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(MySqrt, "RB", "MySqrt", "Input", "User Defined",
    "Returns the square root of the input", "Number whose square "
    "root is to be returned\000", "\0", 1)

extern "C" __declspec( dllexport )
LPXLOPER MySqrt(double dInput)
{
    CXlOper xloResult;
//}}XLP_SRC

    if ( dInput > 0.0 )
        xloResult = sqrt(dInput);
    else
        xloResult = (WORD)(-dInput);

    return xloResult.Ret();
}

Uses

CXlOper::Ret