Groups | Blog | Home
all groups > vb.net controls > june 2006 >

vb.net controls : Why won't this work??


Tony Van
6/25/2006 2:25:49 PM
Can someone help on this. Why does this work:


(cat4 is a true/false database field)

IF DataTable.Rows(CurrRecord)("cat4") = True Then
CkBox5.Checked = True
Else
CkBox5.Checked = False
End IF


...... And this doesn't


IIF (dataTable.Rows(CurrRecord) ("cat4") = True,
CkBox5.Checked = True, CkBox5.checked = False)

(without any error messages)



Tony Van
6/25/2006 4:01:55 PM
OK, I found the answer here
http://secretgeek.net/iif_function.asp

Just another one of the VB gothca's


Herfried K. Wagner [MVP]
6/25/2006 10:00:55 PM
"Tony Van" <ton-jud-ann@comcast.net> schrieb:
[quoted text, click to view]

The values passed to the parameters of 'IIf' are expressions, not
assignments. Thus the value of the 'Checked' property is compared to
'True'/'False'. I'd prefer this solution:

\\\
CkBox5.Checked = DataTable.Rows(CurrRecord)("cat4")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
AddThis Social Bookmark Button