Problem of Creating user define functions of XLL (excel)

When I debug this function into XLL file and run it in excel I get a weird number 1463342408 for wpsum(2,3). any body can help me on this.
Many thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// UDFs.cpp
#include <windows.h>
#include <xlcall.h>
#include "framewrk.h"
#include <stdio.h>

#define NUM_RESULTS 4

__declspec(dllexport) LPXLOPER12 WINAPI wpsum (double a,double b)
{

 	static XLOPER12 xResult;
	static XLOPER12 xArray[NUM_RESULTS];
	int i = 0;
	for (i = 0; i < NUM_RESULTS; i++)
	{
		xArray[i].xltype = xltypeNum;
	}
	
	xArray[0].val.num = a;
	xArray[1].val.num = b;
	xArray[2].val.num = 0;
	xArray[3].val.num = 0;

    xResult.xltype = xltypeMulti| xlbitDLLFree;
	xResult.val.array.lparray =  xArray;
	xResult.val.array.rows = 1;
	xResult.val.array.columns = NUM_RESULTS;
	return &xResult;
 
}
oh my god, my post was buried so fast
Last edited on
hello
Topic archived. No new replies allowed.