ComponentOne True DataControl 8.0
Constant and Non-String Expressions

Normally, an expression is a string, which is evaluated according to True DataControl expression language rules (based on VBScript). But it can also be a constant value of any variant sub-type, not necessarily a string.

Expressions specified at design time are always strings, since there is no way to specify anything but a string in the property pages. You must always remember that expressions you enter in property pages will undergo evaluation. If you want a constant expression, you should enclose it in double or single quotes.

At run time, an expression property can be set to a variant value of any variant data type. If an expression is set to a non-string variant, True DataControl considers such expression constant, always evaluating to the same value, which was assigned to it. For example,

Example Title
Copy Code
TData1.Fields(“CalcAmount”).CalculatedExpression = 1000

will always produce the same result: 1000."

An expression of string type is considered constant if the string is enclosed in quotes. For example, the following constraint message expression specified in property pages is constant:

Example Title
Copy Code
“my message”

To specify this expression in code you should write:"

Example Title
Copy Code
TData1.Constraints(0).MessageExpression = “””my message”””"

In each of the triple quotes here, one quote is necessary to form a Visual Basic string constant. The first character of that constant is a double quote, but since it is in a string constant, it should be written as two double quotes. Hence the triple double quotes.

To make it more readable, True DataControl allows single quotes, as well as double quotes, to form string constants. Then the double quote character can be used inside single quotes without duplication. And vice versa, the single quote character can be used inside double quotes without duplication. So our example can also be written as:

Example Title
Copy Code
TData1.Constraints(0).MessageExpression = ‘”my message”’"

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback