Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NVL() in VB?
Message
From
23/06/2006 15:19:36
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
23/06/2006 14:24:02
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Miscellaneous
Thread ID:
01131276
Message ID:
01131288
Views:
14
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform