算术运算符用于组合数字、数值变量、数值字段和数值函数以得到另一个数字。
算术运算符是加 (+)、减 (-)、乘 (*)、除 (/)、整除 (\)、求余 (Mod)、求反 (-) 和求幂 (^)。
示例
'Outstanding preferred stock as a percent of 'common stock formula = ({Financials.Preferred Stock} / _ {Financials.Common Stock}) * 100 'The square root of 9, Sqr(9), is 3. 'The formula returns 17. formula = 7 + 2 * 3 - 2 + Sqr(6 + 3) * Len("up")
一般情况下,程序按下面的顺序对表达式求值:
Crystal Reports 中算术运算符的优先顺序与 Visual Basic 中的相同。下面是优先顺序从高到低排列的运算符:
示例
从左到右,先进行乘和除运算。然后进行加和减运算。例如,5 + 10 * 3 = 5 + 30 = 35。
使用圆括号可以更改优先顺序。例如,(5 + 10) * 3 = 15 * 3 = 45。如果不能确定优先顺序,最好用括号阐明意图。