IIF behaviour 
Author Message
 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.

Jasmine
www.datagridcolumnstyles.net
Custom DataGridColumnStyles for the Microsoft .Net Windows Forms DataGrid


Quote:
> Hello:

> 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).

> Any ideas?

> [from the documentation]
> Public Function IIf( _
>    ByVal Expression As Boolean, _
>    ByVal TruePart As Object, _
>    ByVal FalsePart As Object _
> ) As Object



Mon, 31 Jan 2005 04:19:31 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Strange IIf behaviour

2. logic with IIF Statements

3. IIF

4. IIF in SQL

5. IIF function

6. With an Access IIF Statement...

7. Error when using iif in report

8. Outlook 9 Library stops IIf Query in run time

9. IIF for Spencer

10. IIF for Spencer (Pt.2)

11. Using IIF in update query

12. IIF help for all values

 

 
Powered by phpBB® Forum Software