I have code that works:
And the following which does not work:Code:If IsDBNull(dbReader("cost")) Then Me.CostTextBox.Text = String.Empty Else Me.CostTextBox.Text = FormatCurrency(dbReader("cost"), 2) End If
It returns the error "Conversion from type DBNULL to type Currency is not valid" when dbReader("cost") is null. If dbReader("cost") is null it should put String.Empty in Me.CostTextBox, just like the first code. It shouldn't be hitting the currency function at all.Code:Me.CostTextBox.Text = IIf(IsDBNull(dbReader("cost")), String.Empty, FormatCurrency(dbReader("cost"), 2))
I can always use the first method but I'd like to know why the Iif doesn't work.
Using VB.Net Express 2010.




Reply With Quote