Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

比較域代碼會比較兩個值,如果比較為 True,則會顯示結果 「1」,如果比較為 false,則會顯示 「0」 (零) 。 您可以使用此欄位在 = (Formula) 欄位中,使用 And 及 Or 函數建立複合邏輯比較,然後在 If 欄位中使用 = (Formula) 字段的結果。

語法

當您在檔案中檢視 [比較] 域代碼時,語法看起來像這樣:

{ COMPARE Expression1 運算符 Expression2 }

附註:  功能變數代碼會指示功能變數該顯示的內容。 功能變數結果是指評估功能變數代碼之後,顯示在文件中的內容。 若要切換檢視功能變數代碼和功能變數代碼結果,請按 Alt+F9。

指示

Expression1,Expression2

要比較的值。 表達式可以 書籤 名稱、文字字串、數位、傳回值的巢狀欄位,或數學公式。 如果表達式包含空格,請以引弧括住運算式。

運算子​​

比較 運算子。 在運算子前後插入一個空格。

運算子​​

描述

=

等於

<>

不等於

>

大於

<

小於

>=

大於或等於

<=

小於或等於

附註: 如果運算子是 =<>,Expression2 可以包含問號 (?) 代表任何單一字元,或是星號 (*) 來代表任何字串。 表達式必須以引號括住,才能將其比較為字元字串。 如果您在 Expression2 中使用星號, 則 Expression1 對應到星號的部分,加上 Expression2 中的任何剩餘字元,不能超過 128 個字元。

範例

假設下列範例中的 If 功能變數已插入郵件合併主文件。 [比較] 欄位會在每個 資料記錄 合併時,檢查 [CustomerNumber] 和 [CustomerRating] 數據字段。 = (Formula) 欄位的 Or 函數會在至少其中一個數據欄位指出不佳的分數時,傳回值 「1」 (true) ,在這種情況下,會列印引號中的第一個文字。

{ 如果 { = 或 ( { compare { MERGEFIELD CustomerNumber } >= 4 }{ COMPARE { MERGEFIELD CustomerRating } <= 9 } ) } = 1 “Credit not acceptable” “Credit acceptable”}

如果 PostalCode 數據欄位中的任何值是範圍 98500 – 98599,下列 Compare 功能變數會產生值 “1”:

{ COMPARE “ { MERGEFIELD PostalCode } ” = “985*” }

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×