Crystal Reports Designer  

函式總覽 (Basic 語法)

在公式中使用函式時,請輸入函式的名稱以及必要的引數。例如,Len 函式需要 String 引數,並計算該字串的長度。

Dim x As String
x = "hello"
formula = Len (x) 'The formula returns the Number 5

如果輸入的引數型別不是函式所要求的型別,將會導致錯誤。例如,呼叫 Len (3) 會產生錯誤,因為 Len 不接受數字引數。

但是,有時候函式可接受不同數目的引數或不同型別的引數。例如,CDate 函式可以接受單一的 String 引數來建立日期值,或接受三個數字值 (分別代表年、月、日) 來建立日期值。請參閱日期、時間和日期時間

Mid 函式範例

Dim x as String
x = "hello"
'Start at position 2, go to the end of the string
formula = Mid (x, 2) 'formula is now "ello"
'Start at position 2, extract 1 character
formula = Mid (x, 2, 1) 'formula is now "e"

函式的類別有:數學、摘要、財務、字串、日期/時間、日期範圍、陣列、型別轉換、程式捷徑、驗算時間、列印狀態、文件屬性和其他函式。另外還有一些和條件式格式化公式有關的函式。

與 Visual Basic 函式類似的函式

數學、財務、字串、日期/時間、型別轉換和程式捷徑群組包含的主要函式均是 Visual Basic 使用者熟悉的。多數的函式與 Visual Basic 中相同名稱的函式功能相當。

請參閱

執行報表計算