วันจันทร์ที่ 2 กุมภาพันธ์ พ.ศ. 2552

การประกาศตัวแปรใน Crystal Report

Variable Declarations

Before we can use a variable in a formula, it has to be declared. Basic and Crystal Syntax both have different ways of declaring variables, based on the type and scope of the variable. The most common variable declarations are included below:

Crystal Report สามารถ ประกาศตัวแปร ได้ 2 ภาษา คือ Basic และ Crystal โดยมีการเปรียบเทียบ ดังตารางข้างล่างนี้

Basic

Crystal

Dim x

n/a

Dim x ()

n/a

Dim x As Boolean

Local BooleanVar x

Dim x As Number

Local NumberVar x

Dim x As Currency

Local CurrencyVar x

Dim x As Date

Local DateVar x

Dim x As Time

Local TimeVar x

Dim x As DateTime

Local DateTimeVar x

Dim x As String

Local StringVar x

Dim x As Number Range

Local NumberVar range x

Dim x As Currency Range

Local CurrencyVar range x

Dim x As Date Range

Local DateVar range x

Dim x As Time Range

Local TimeVar range x

Dim x As DateTime Range

Local DateTimeVar range x

Dim x As String Range

Local StringVar range x

Dim x () As Boolean

Local BooleanVar array x

Dim x () As Number

Local NumberVar array x

Dim x () As Currency

Local CurrencyVar array x

Dim x () As Date

Local DateVar array x

Dim x () As Time

Local TimeVar array x

Dim x () As DateTime

Local DateTimeVar array x

Dim x () As String

Local StringVar array x

Dim x () As Number Range

Local NumberVar range array x

Dim x () As Currency Range

Local CurrencyVar range array x

Dim x () As Date Range

Local DateVar range array x

Dim x () As Time Range

Local TimeVar range array x

Dim x () As DateTime Range

Local DateTimeVar range array x

Dim x () As String Range

Local StringVar range array x

To select a scope for variables created in Basic syntax, you can use the following scope attributes in place of the Dim statement:

การเลือกใช้ตัวแปร หรือชนิดของตัวแปร จะมีข้อกำหนด หรือข้อจำกัด ของการประกาศค่า

  • Local - The variable is specific and can only be used in the formula in which it is defined. เป็นตัวแปรแบบ Local ใช้ใน Local ได้อย่างเดียว

  • Global - The variable is available to formulas throughout the entire current report. เป็นตัวแบบ Global การประกาศตัวแปรนี้ สามารถมองเห็นได้ทั้ง Report

  • Shared - The variable can be shared with a subreport as well as the entire current report. เป็นตัวแปรแบบ Shared ซึ่งส่วนมากจะให้กับ Subreport

Credit : http://theera.exteen.com/20060831/variable-declarations


0 ความคิดเห็น: