PDA

View Full Version : Error in Statistica Visual Basic macro



kobylkinks
02-10-2009, 06:51 AM
Hi guys.

I'm having a problem writing Statistica Visual Basic macro.
Look at the code:

Dim har () As Double, sample () As Double, card As Byte

...

ReDim har (1 To S1.NumberOfVariables) As Double
'S1 is active spreadsheet

...

ReDim Preserve sample(1 To card) As Double
ValStDeviation (sample, 1, card, har(j))

I get "Expecting already dimensioned array" error.
If one looks at ValStDeviation function description it is as follows:

ValStDeviation(ByRef arr() As Double, ByVal Start As Long, ByVal Count As Long, ByRef result As Double) As Long
The ValStDeviation function returns the standard deviation of the values from among the specified number of array elements beginning with the specified element and places in the result variable.

Any thoughts on why this error might occur ?
Thanks in advance.

kobylkinks
02-11-2009, 01:10 AM
I got it guys.

All I need to do is to put the comment

'$include: "*STB.svx"

in the beginning.

SlideRule
02-11-2009, 06:32 AM
Thank you for posting your fix. I use Statistica; I think it is a great tool and I'm happy when I see it getting traffic in stats forums.