IIF behaviour

IIF behaviour

Author

Message

.net datagridcolumnstyle#1 / 1

IIF behaviour

Hi Matt It also says in the documentation .... Remarks Note The expressions in the argument list can include function calls. As part of preparing the argument list for the call to IIf, the Visual Basic compiler calls every function in every expression. This means that you cannot rely on a particular function not being called if the other argument is selected by Expression.

In C# you could have used the ? : operator which doesn't evaluate the second or third operands unless it has to. I'm not aware that VB has an equivalent of this operator.

Sorry that's not really helped, but at least you know why it's not working ;) J.

> I had some code that has an IIF that was working > previously, but now generates an error. Even though the > condition evaluates to false, it executes the true > expression for some reason, which gives a run-time > exception. Why would it execute the "true" expression?

> (In the image attached, snBookSetup is a DataRow, theData > is a DataSet).