Exporting XtrFun Functions to VB
1. If you plan to use XlXtrFun.xll worksheet functions only, that is, if you are NOT going to program in a programming language such as Visual Basic, C/C++, or FORTRAN, you can ignore this email.
2. Excel comes with the programming language Excel Visual Basic for Applications (VBA). Excel VBA is nearly identical to Visual Basic (VB). However, VB can create stand-alone executable programs (*.exe, *.dll, etc. files) whereas VBA programs are part of an Excel workbook (*.xls) and therefore can run only within Excel. Other than the ability to work outside of Excel, the only other limitation of VBA that I have encountered (and this is after years of programming large and complex programs in VBA) is VBA's lack of the AddressOf operator (which VB has). (AddressOf enables the use of callback functions that are used by a few Windows API functions). However, this lack is a small price to pay for the convenience of handy spreadsheets and charts that are so vital for technical work.
If you are going to program in VBA, then the following introduction will be helpful.
You can use many, but not all, of Excel's intrinsic worksheet functions in a VBA program; e.g.,
Debug.Print Application.WorksheetFunction.Sum(2, 3)
causes 5 to appear in the debug window.
Unfortunately, XlXtrFun.xll worksheet functions are not part of the Application.WorksheetFunction object, so that technique doesn't work.
Fortunately, XlXtrFun.xll has exported versions of the XlXtrFun.xll worksheet functions that can be used in your VBA project. Rather than waste a lot of words, you can see how they work by looking at the workbook, VB Declarations.xls.
3. If you are going to program ONLY in Excel VBA, never in VB, C/C++, FORTRAN, etc., then you can ignore the rest of this email.
If you are going to program outside of the Excel VBA environment, then...
The functions in XlXtrFun.xll work only within Excel, either on a spreadsheet or in an Excel VBA project. They are not exported for use by other languages such as VB. I have fixed this problem by making a separate DLL (XtrFun.dll) with all the numeric routines in it.
Put XtrFun.dll in the path. I recommend C:\Windows\System32, C:\Winnt\System32, or something similar.
Only the functions in the DLL will be able to be used by programs other than Excel VBA. Just look at the VBA module, mXtrFunDllDeclarations, in VB Declarations Release 200103.xls to see what functions are working from the DLL (vice the XLL). Although this is an Excel VBA project, these DLL functions should work outside of Excel, e.g., in pure VB.
You will notice that the functions in the DLL have "xtf_" in front of their names.
I have included a VB project Add42 that tests whether it can find the DLL. If that program runs, then all the other functions should run, too.
XtrFun.dll is a work in progress. It is not finished yet. Please feel free to contact me with any problems or suggestions.
I hope this helps.
Have fun,
Scott Allen Rauch
ô¿ô
www.netrax.net/~jdavita
"One should not attribute to malice what can be explained by stupidity, AND one should not attribute to stupidity what can be explained by ignorance."
[Wesley R. Elsberry at http://www.talkorigins.org/origins/jargon/jargon.html]