> ## Content Index
> Fetch the complete content index at: https://blog.tsd.digital/llms.txt
> Use this file to discover other available public pages before exploring further.

# IIf Issues
- URL: https://blog.tsd.digital/iif-issues/
- Published: 2006-09-30T11:39:47.000Z
- Updated: 2006-09-30T11:39:47.000Z
- Author: Tim Gaunt
- Tags: ASP.Net, .Net, #Import 2025-04-01 05:34

Sean Ronan (from [Activepixels.co.uk](http://www.activepixels.co.uk/?ref=blog.tsd.digital)) was asking me the other day why he was receiving a “Cannot convert ‘’ to DateTime” when writing:

IIf(String.IsNullOrEmpty(DateOfBirth.Text), Nothing, CDate(DateOfBirth.Text))

Thanks to [Doug Setzer](http://www.27seconds.com/?ref=blog.tsd.digital) from [27Seconds](http://www.27seconds.com/?ref=blog.tsd.digital) in pointing him in the right direction, unlike C#’s ability to write:

(TrueFalseStatement ? TruePart : FalsePart)

VB’s IIf is a function not a statement so unlike C#’s equivielent which is run un-evaluated, VB’s IIf function evaluates both sides of the statement regardless of whether the statement is true of false.

Yet another reason to use C# IMNSHO :-)