FlexReport for WinForms
VBScript 要素
VBScript の操作 > VBScript 要素

The following tables detail VBScript elements, objects, and variables.

Operators

The following table contains the VBScript operators:

Operator Description
And Performs a logical conjunction on two expressions.
Or Performs a logical disjunction on two expressions.
Not Performs a logical disjunction on two expressions.
Mod Divides two numbers and returns only the remainder.

Reserved symbols

The following table contains the VBScript reserved symbols and how to use them:

Keyword Description
True The True keyword has a value equal to -1.
False The False keyword has a value equal to 0.
Nothing Used to disassociate an object variable from any actual object. To assign Nothing to an object variable, use the Set statement, for example: Set MyObject = Nothing Several object variables can refer to the same actual object. When Nothing is assigned to an object variable, that variable no longer refers to any actual object. When several object variables refer to the same object, memory and system resources associated with the object to which the variables refer are released only after all of them have been set to Nothing, either explicitly using Set, or implicitly after the last object variable set to Nothing.
Null The Null keyword is used to indicate that a variable contains no valid data.
vbCr When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbCrLf When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbLf When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbFormFeed When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbNewLine When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbNullChar When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbTab When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbVerticalTab When you call print and display functions, you can use the following constants in your code in place of the actual values.
vbBlack Black. Value = 0x0.
vbRed Red. Value = 0xFF.
vbGreen Green. Value = 0xFF00.
vbYellow Yellow. Value = 0xFFFF.
vbBlue Blue. Value = 0xFF0000.
vbMagenta Magenta. Value = 0xFF00FF.
vbCyan Cyan. Value = 0xFFFF00.
vbWhite White. Value = 0xFFFFFF.

Built-in functions

The VBScript built-in functions are listed below:

Abs Date Iif Minute Sign
Acos DateAdd InputBox Month Space
Asc DateDiff InStr MonthName Sqr
Asin DatePart InStrRev MsgBox StrComp
Atn DateSerial Int Now String
CBool DateValue IsDate Oct Tan
CByte Day IsEmpty Pi Time
CCur Exp IsNull Replace Timer
CDate Fix IsNumeric RGB TimeSerial
CDbl Format IsObject Right TimeValue
Chr FormatCurrency LCase Rnd Trim
CInt FormatDateTime Left Round TypeName
CLng FormatNumber Len RTrim UCase
Cos FormatPercent Log Second WeekDay
CSng Hex LTrim Sgn WeekDayName
CStr Hour Mid Sin Year

For more information on the VBScript functions, see the MSDN documentation.

The key features of VBScript that are part of C1FlexReport are as follows:

Built-in script functions, Like and In have functionality similar to SQL operators LIKE and IN and return True or False.
Like(str, template): Compares 'str' to 'template', which can contain wildcard '%'. Some examples of Like function are as follows:

In(obj, obj1, ... objN): Tests whether 'obj' is among objects 'obj1', ... , 'objN'. Some examples of In function are as follows:

As you can observe, both the functions are case-sensitive, so "abc" is not the same as "Abc".

Note that the following VBScript features are not supported in C1FlexReport:

Statement keywords

The VBScript statement keywords are listed below:

If ElseIf To While Dim
Then EndIf Next Wend Redim
Else For Step Const

Report Field Names

Names of Field objects are evaluated and return a reference to the object, so you can access the field's properties. The default property for the Field object is Value, so by itself the field name returns the field's current value. For example:

MyField.BackColor = RGB(200,250,100)
MyField.Font.Size = 14
MyField * 2 ' (same as MyField.Value * 2)
Note: If you give a report field the same name as a database field, you won't be able to access the report field.

Report Section Names

Names of Section objects are evaluated and return a reference to the object, so you can access the section's properties. The default property for the Section object is Name. For example:
If Page = 1 Then [Page Footer].Visible = False

Database Field Names

Names of fields in the report's dataset source are evaluated and return the current field value. If a field name contains spaces or periods, it must be enclosed in square brackets. For example:

OrderID
UnitsInStock
[Customer.FirstName]
[Name With Spaces]

Report Variables

Page

The page variable returns or sets the value of the Page property. This property is initialized by the control when it starts rendering a report, and is incremented at each page break. You may reset it using code. For example:

If Country <> LastCountry Then Page = 1
LastCountry = Country

Pages

The pages variable returns a token that gets replaced with the total page count when the report finishes rendering. This is a read-only property that is typically used in page header or footer fields. For example:
"Page " & Page & " of " & Pages

Report Object

The report object returns a reference to the control object, so you can access the full C1FlexReport object model from your scripts and expressions. For example:

"Fields: " & Report.Fields.Count

Cancel

Set Cancel to True to cancel the report rendering process. For example:

If Page > 100 Then Cancel = True