つらつら Excel VBA

私の備忘録です。

If 1<2<3 Then

文法エラーにならない。怖い。

If 1 < 2 < 3 Then
    Debug.Print "1.True"
End If

If 3 < 2 < 1 Then
    Debug.Print "2.True"
End If

If True > True > True Then
    Debug.Print "3.True"
End If


順番に一つ一つ比較する。
1の例。1<2はTrue、Int(True)は-1、-1<3はTrue。
2の例。3<2はFalse、Int(False)は0、0<3はTrue。
3の例。Int(True)は-1、-1>-1はFalse、Int(False)は0、0>-1はTrue。


正しく動いても怖い。

以上。