Which kind of output can I create with SVB?

There are a number of possible ways to display results, numbers, messages, etc. generated with a Statistica Visual Basic program. Most often, you will want to present results in spreadsheets, graphs, or reports. A very useful method for sending results spreadsheets and graphs to a current default "place" (workbook, stand-alone window, report) is to use the RouteOutput method. However, you can also copy and paste results from Statistica into spreadsheets, text documents, etc., as long as those other types of output objects ("belonging" to other applications, such as Microsoft Excel or Word) support the Visual Basic standards.

Probably, the method you will most frequently use to display results is via spreadsheets and graphs; occasionally, you may also want to write some text or tables into a report. All of these are supported as objects, in the Statistica Visual Basic object model (see What is meant by the term "object model?"). For example, the following program will produce a spreadsheet, a line graph, and a report that will contain the spreadsheet and the line graph. All of these output objects will then be placed into a new workbook.

Note: the following program does not use the RouteOutput method to send the spreadsheet and graph to a default location (e.g., workbook) as currently defined via the Analysis/Graph Output Manager. Instead, the program illustrates how you can explicitly create spreadsheet and graph objects and move them to the location of your choosing.

Sub Main

Dim newanalysis As Analysis ' Create a new workbook; by default it will be ' empty and "invisible." Dim wb As New Workbook ' Create a new report; by default it will be ' empty and invisible. Dim r As New Report ' Create a new Spreadsheet; by default it will ' contain 10 rows and 10 columns, and it will ' be invisible. Dim ss As New Spreadsheet ' Declare an object of type Graph; we will ' create it later as a line graph. Dim g As Graph Dim NumberOfRows As Long Dim NumberOfColumns As Long Dim i As Long,j As Long NumberOfRows=100 NumberOfColumns=5 ' Note how we can dynamically "re-dimension" arrays. ReDim x(1 To NumberOfRows, _ 1 To NumberOfColumns) As Double ' Here we fill the data array x with numbers For i=1 To NumberOfColumns For j=1 To NumberOfRows x(j,i)=Exp(j*i/500) Next j Next i ' Next put the numbers into the spreadsheet ss. First ' we will resize the default (10 x 10) spreadsheet ' to make room for the 100 x 5 data matrix. ss.SetSize(NumberOfRows,NumberOfColumns) ' The following line is a shortcut method for copying ' the entire array into the spreadsheet. ss.Data=x ' Alternatively, the following loop could be used. ' For i=1 To NumberOfColumns '  For j=1 To NumberOfRows '    ss.Value(j,i)=x(j,i) '  Next j ' Next i ' Create a new analysis object of type line plot; pass ' as input data the contents of spreadsheet ss. Set newanalysis = Analysis (sc2dLinePlots,ss) newanalysis.Dialog.GraphType = scLineMultiplePlot ' Select all variables in the new spreadsheet. newanalysis.Dialog.Variables="*" ' Create the graph, and assign it to the previously ' declared object g. Note that all results from analyses ' in Statistica are returned as collections, and by default ' all results objects are invisible. Set g=newanalysis.Dialog.Graphs.Item(1) ' Now let us "print" both results to the report. r.SelectionObject=ss r.SelectionObject=g ' Finally, move the new objects (spreadsheet ss, ' graph g, and report r) to the workbook. wb.InsertObject(ss,wb.Root,) wb.InsertObject(g,wb.Root,) wb.InsertObject(r,wb.Root,) ' Make the final results workbook visible. wb.Visible=True

End Sub

After running this program, a workbook will be created that looks something like this (depending on other default systems currently active in your system).

Note: further customizations, such as changing of titles, adding text, etc. can easily be achieved by further modifying various properties of the output objects, or the workbook.