>Is there an equivalent in VB .Net to VFP's NVL()? This would be similar to SQL Server's COALESCE() function where it returns the first non-null value from a list of parameters.
>
>Thanks,
>Elyse
Elyse,
There is no built-in equivalent of COALESCE(). However, writing your own function is pretty easy to do. Check out ParamArray, Nothing, String.Empty, and System.Data.ISDBNull() in the help files as these are the keys to creating a coalesce function. Perhaps something like this:
Function nvl(ByVal ParamArray p() as Object) As Object
For Each o As Object in p
If (Not (o Is Nothing)) AndAlso (Not System.Data.IsDBNull(o)) AndAlso (Not (o = String.Empty))
Return o
Exit For ' Belt & suspenders
End If
Next
End Function