IsFalse 運算子 (Visual Basic)IsFalse Operator (Visual Basic)

判斷運算式是否為FalseDetermines whether an expression is False.

您無法在IsFalse程式碼中明確呼叫, 但是 Visual Basic 編譯器可以使用它來產生來自子句AndAlso的程式碼。You cannot call IsFalse explicitly in your code, but the Visual Basic compiler can use it to generate code from AndAlso clauses. 如果您定義了類別或結構, 然後在AndAlso子句中使用該類型的變數, 您必須在該類別或結構上定義。 IsFalseIf you define a class or structure and then use a variable of that type in an AndAlso clause, you must define IsFalse on that class or structure.

編譯器會將IsFalseIsTrue運算子視為相符的配對The compiler considers the IsFalse and IsTrue operators as a matched pair. 這表示如果您定義其中一個, 則也必須定義另一個。This means that if you define one of them, you must also define the other one.


運算子可以多載, 這表示當類別或結構的運算元具有該類別或結構的類型時, 可以重新定義其行為。 IsFalseThe IsFalse operator can be overloaded, which means that a class or structure can redefine its behavior when its operand has the type of that class or structure. 如果您的程式碼在這類類別或結構上使用這個運算子, 請務必瞭解其已重新定義的行為。If your code uses this operator on such a class or structure, be sure you understand its redefined behavior. 如需詳細資訊,請參閱 Operator ProceduresFor more information, see Operator Procedures.


下列程式碼範例會定義包含IsFalseIsTrue運算子之定義的結構外框。The following code example defines the outline of a structure that includes definitions for the IsFalse and IsTrue operators.

Public Structure p
    Dim a As Double
    Public Shared Operator IsFalse(ByVal w As p) As Boolean
        Dim b As Boolean
        ' Insert code to calculate IsFalse of w.
        Return b
    End Operator
    Public Shared Operator IsTrue(ByVal w As p) As Boolean
        Dim b As Boolean
        ' Insert code to calculate IsTrue of w.
        Return b
    End Operator
End Structure

另請參閱See also