Possible Duplicate:
Is there a conditional ternary operator in VB.NET?
Is there a version of the shorthand If-Then-Else in C#:
c = (a > b) ? a : b;
meaning...
if (a > b) {
c = a; }
else {
c = b; }
.. in VB.Net?
You want to use the If operator:
Dim maximum = If(a > b, a, b)
There's also the older Iif function, which still works, but If
is superior, since it:
a
and b
are both integers, the return value will be an integer instead of an object) anda > b
, only a
is evaluated, and vice-versa) -- this is relevant if a
or b
is a function call.Yes the IF
is what you want
Here is some reference
http://msdn.microsoft.com/en-us/library/bb513985
Here is its use
c = IF(a > b, a , b)
Obviously there was a operator called IIF but it has been deprecated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With