ComponentOne FlexReport for WinForms
Working with VBScript
Working with FlexReport > Working with VBScript

VBScript expressions are widely used throughout a report definition to retrieve, calculate, display, group, sort, filter, parameterize, and format the contents of a report. Some expressions are created for you automatically (for example, when you drag a field from the Toolbox onto a section of your report, an expression that retrieves the value of that field is displayed in the text box). However, in most cases, you create your own expressions to provide more functionality to your report.

Note the following differences between VBScript expressions and statements:

C1FlexReport relies on VBScript to evaluate expressions in calculated fields and to handle report events.

VBScript is a full-featured language, and you have access to all its methods and functions when writing C1FlexReport expressions. For the intrinsic features of the VBScript language, refer to the Microsoft Developer's Network (MSDN).

Global Scripts can be written in the new VBScript Editor. This editor allows users to define VBScript functions and subroutines that are accessible throughout the report. To directly access the VBScript Editor, press F7 and to close the editor and save the changes, use the shortcut key Ctrl+W. Users can switch between scripts and also change options such as fonts or colors within the editor. The editor also makes the scripting experience intuitive and easy for developers with advanced features such as syntax check, pre-defined VBScript functions, and rearranged scripting functions.

To write global scripts using VBScript Editor option,

  1. Go to Home Tab of C1FlexReportDesigner.
  2. Click VBScript Editor and write desired global script; for example,

        function Backcolor()
        Detail.Backcolor=rgb(255,0,0)
        end function

You can also write global scripts using GlobalScripts property of C1FlexReportDesigner as follows:

  1. Select the report in which you want to write global script.
  2. Go to the GlobalScripts property of the report and then click ellipsis. This opens VBScript Editor dialog box.
  3. Write the global script as above, in the VBScript Editor.
                                           
    

VBScript Editor in C1FlexReportDesigner
So, you have defined a global function 'Backcolor()', which can be used throughout the report.

The VBScript Editor has the following additional features:

Note that Global Scripts dropdown in VBScript Editor is enabled only if you have previously defined global script(s) in your report.

C1FlexReport extends VBScript by exposing additional objects, variables, and functions. These extensions are described in the following sections.

See Also