jeudi 20 août 2020

Why does VBA consider -1 < 3 < 2 to be True?

I have an If statement that checks whether a value is between two integers. A simple check, which I thought I could tackle through -1 < x < 2 where x contains any integer.

However, when x = 3 for example, VBA considers the statement to be true, even though this clearly is not the case.

I know I can simply avoid this issue by using If -1 < x And x < 2 Then instead, but I'd like to know why the former statement doesn't produce the expected output. I tried looking online for an answer, but failed to find any.

Aucun commentaire:

Enregistrer un commentaire