# x=Power(x,y) not working in Basic

Slowly working out calculations, but became stumped when it appear that =Power(x,y) does not seem to work. Dialog box pops up "BASIC runtime error. Sub-procedure or function procedure not defined."

It works fine in the spreadsheet, but I need it's operation in the function to pass back a single result.

edit retag close merge delete

If you use a BASIC user defined function, then you should provide the macro code, so that the code could be inspected, tested and analyzed. Otherwise stick with @mauricio's advice to use the power function of LibreOffice.

( 2020-01-03 23:45:43 +0200 )edit

Spreadsheet functions are not Basic functions. Sometimes some Basic functions have same names as spreadsheet functions, but that is coincidence. Generally you need to use FunctionAccess service in a macro to have access to the spreadsheet functions, e.g. like described here.

( 2020-01-04 00:08:22 +0200 )edit

Sort by » oldest newest most voted
more

2

Quoting @Mike Kaganski (from the comment on the question): "Sometimes ... Basic functions have same names as spreadsheet functions, ..."
But neither the same (mathematical) function will always have the same name as a spredsheet function and in Basic (if it exists at all in both worlds) nor can we be sure that functions existing under a specific name in Basic and in Calc are the same thing in both cases. Some are working slightly different. In at least one really "dangerous" case two equally named functions mean very different things. And the case lies in the the field under discussion here:
The LOG() function in Calc has an optional second parameter for the base which defaults to 10 while the Log() function in Basic uses the base e (2.718...). The second one is also called the "natural logarithm" and is also available in Calc, but as LN().
(The EXP() in ...(more)

( 2020-01-04 01:26:09 +0200 )edit