The following works:
If 1=1
rdoYes.checked = True
Else
rdoNo.checked = True
End If
However, the following doesn’t work:
IIF(1=1, rdoYes.checked = True, rdoNo.checked = True)
Why is this?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It does “work”; it just doesn’t do what you want.
IIfin VB.NET is a function (don’t use it, ever, by the way), which takes these parameters:Booleancondition to checkObjectto return if the condition isTrueObjectto return if the condition isFalseIn your usage, your condition is
1 = 1; then your two other parameters arerdoYes.Checked = TrueandrdoNo.Checked = True, bothBooleanexpressions from the VB compiler’s perspective (so, really, they’re equivalent to the simplerrdoYes.CheckedandrdoNo.Checked).Remember that in VB.NET, the
=sign is only an assignment if it is on its own line. This is how the compiler distinguishes between statements such asx = 5andIf x = 5 Then.This is not directly related to your question, but you should also be aware that
IIfis deprecated and you should almost always favorIfinstead: