Can someone help me to understand why If/Then/End If works but IIf doesn't?
I ran my code with this and it works as expected:
For Each BtnObj In Padre.Controls
With BtnObj
If nullinator(.Tag) = 0 Then
.Visible = False
Else
.Visible = True
End If
End With
Next
Here's my "nullinator" function:
Public Shared Function nullinator(ByVal CheckVal As String) As Integer
' Receives a string and returns an integer (zero if Null or Empty or original value)
If String.IsNullOrEmpty(CheckVal) Then
Return 0
Else
Return CheckVal
End If
End Function
However, if I run it using this code, nullinator(.Tag) = 0 always equates to be False even if the contents of Tag property is empty. Here's the code:
For Each BtnObj In Padre.Controls
With BtnObj
IIf(nullinator(.Tag) = 0, .Visible = False, .Visible = True)
End With
Next
Oh yes, the "Padre" variable is the container (parent) object.
Any insights why I'm not having success using IIf would be greatly appreciated!