give the example of using IIF statement [Resolved]

Posted by Maheshvishnu under ASP.NET on 9/21/2012 | Points: 10 | Views : 1170 | Status : [Member] | Replies : 5
please give the example of IIF statement


IIF is similar to ternary expressions in C language

mahesh


Responses

Posted by: Vikash on: 9/21/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
IIF is not a language feature but a function within the Microsoft.VisualBasic namespace
IIF function could be better implemented by using generics (to avoid the typecasting).
Syntax

Public Function IIf(Of T)(ByVal expression As Boolean, _

ByVal truePart As T, ByVal falsePart As T) As T

If expression Then

Return truePart

Else

Return falsePart

End If

End Function


Example----
If expression is true TruePart is returned, otherwise FalsePart is returned.

Dim StdBool As Long, VbBool As Boolean
VbBool = False
StdBool = IIf(VbBool, 1, 0)

Mark as answer if it is helpful...



Regards,
Vikash Pathak

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
Dear mahesh

which language(vb.net or SQL) u want the example in.?

Regards,
Vikash Pathak

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
What is IIF?

Thanks & Regards
Hari

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Maheshvishnu on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
it was similar to if else statement

mahesh

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Maheshvishnu on: 9/21/2012 [Member] Starter | Points: 25

Up
0
Down
give example in vb.net
vikas

mahesh

Maheshvishnu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response