I have nullable decimal variable.
I can assign null (nothing) to it.
Everything works fine, until I try to assign null (nothing) to it from If() or IIf() functions!
Somehow tests done in aftermentioned functions return wrong logical result!
Am I missing something??? i'm so tired by now, that it is possible :) help please!
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<div>
@Code
Dim dec As Decimal? = Nothing
If dec Is Nothing Then
' works correctly
@:Nothing
Else
@dec
End If
@<br />
Dim strx = ""
dec = If(Len(strx) > 0, strx.AsDecimal(), Nothing)
If dec Is Nothing Then
@:Nothing
Else
' WHY this code goes here ??? dec should be nothing!!!!!
@dec
End If
End Code
</div>
</body>
</html>
trolis
Member
102 Points
43 Posts
Another bug ?? If() function this time...
Jun 06, 2011 11:47 AM|LINK
I have nullable decimal variable.
I can assign null (nothing) to it.
Everything works fine, until I try to assign null (nothing) to it from If() or IIf() functions!
Somehow tests done in aftermentioned functions return wrong logical result!
Am I missing something??? i'm so tired by now, that it is possible :) help please!
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <div> @Code Dim dec As Decimal? = Nothing If dec Is Nothing Then ' works correctly @:Nothing Else @dec End If @<br /> Dim strx = "" dec = If(Len(strx) > 0, strx.AsDecimal(), Nothing) If dec Is Nothing Then @:Nothing Else ' WHY this code goes here ??? dec should be nothing!!!!! @dec End If End Code </div> </body> </html>