ターゲット オブジェクトが入力規則を満たすかどうかを示す論理式を取得または設定します。 値の取得と設定が可能です。
構文
expression。 TestExpression
式ValidationRule オブジェクトを表す変数。
戻り値
String
注釈
Validate メソッドを呼び出すか、[プロセス] タブの [図の確認] をクリックして図を検証すると、Microsoft Visio では、TestExpression プロパティ値として設定したテスト式を使用して、ターゲット オブジェクトが入力規則を満たしているかどうかが判断されます。 テスト式が False の場合は、検証の問題が生成されます。 テスト式が True であると評価された場合、検証の問題は生成されません。
Visio では、ValidationRule オブジェクトの FilterExpression プロパティの値が True と評価された場合にのみ、ターゲット オブジェクトのテスト式が評価されます。
TestExpression プロパティの値の構文は、シェイプシート式の構文と同じです。 TestExpression プロパティの値を設定するとき、テスト式の構文はチェックされません。 テスト式の構文が正しくない場合、検証中に式の評価が失敗し、その時点で検証の問題が生成されます。
例
次の Visual Basic for Applications (VBA) の例は、TestExpression プロパティを使用して、特定の図形ターゲットが入力規則を満たしているかどうかを判断する方法を示しています。
' Add a validation rule to the document.
Set vsoValidationRule = vsoValidationRuleSet.Rules.Add("Unglued2DShape")
vsoValidationRule.Category = "Shapes"
vsoValidationRule.Description = "This 2-dimensional shape is not connected to
any other shape."
vsoValidationRule.Ignored = False
vsoValidationRule.TargetType = Visio.VisRuleTargets.visRuleTargetShape
' The validation function Is1D() returns a Boolean value that indicates
' whether the shape is 1D (True) or 2D (False).
vsoValidationRule.FilterExpression = "NOT(Is1D())"
' The validation function GLUEDSHAPES returns a set of
' shapes glued to the shape.
' It takes as input one parameter that indicates the direction of the glue.
' The direction values are equivalent to members of VisGluedShapesFlags:
' 0 = visGluedShapesAll1D, and 3 = visGluedShapesAll2D
' It takes as input one parameter indicating the direction of the glue.
' The validation function AGGCOUNT takes a set of shapes as its input, and
' returns the number of shapes in the set.
vsoValidationRule.TestExpression = "AGGCOUNT(GLUEDSHAPES(0)) + AGGCOUNT(GLUEDSHAPES(3)) > 0"
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。