View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Creating vectors of numbers

"Harlan Grove" wrote:

I said easy, not fast. If you want fast, this is a case in which VBA
looks are faster. However, if fast is the goal, there are faster
approaches than your LoopArray function.

First, only use error checking when necessary. In this case, it's not.
You can (and should) check your arguments before allocating your
return array and looping through it. Error checking slows things down.

Second, use integers (best, Longs) for For loop control variables, and
it's almost always best to loop on the array index, not the values
that would be stored in the array.

So here are functions to return horizontal and vertical arrays.


not unexpected ...
... i just thought you might come back with some 'pure' code.
<VBG

you're correct.. my code wasn't optimed for speed either.
my point was merely to demonstrate the relative slowness of the
the evaluate/row construct

re the errorhandler..
the way I used the errohandler to jump out of illegal input, may not be
gracefull but does NOT slow it down, at least i tried to test this but
could find no difference (even with large arrays or very high number of
calls to the function.

which I'd like to explain like this:
when I dont define an errorhandler the default errorhandler is
implicitly active e.g on error goto 0..

as long as my code doesnt jump back and forth between labels due to
trapped but resumed or handled code there should be no difference.


my bonus.. your 'pure' code


thanks!



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool