Link to home
Start Free TrialLog in
Avatar of tyy8
tyy8

asked on

Converting empty strings to Null

Is there a pre-existing function in VB.NET that converts an empty string to Null, or do you have to write it for yourself.
Avatar of graye
graye
Flag of United States of America image

An empty string is not the same as a null (in practically any language).  Tell us what you're trying to do (perhaps there is a better way to accomplish the goal).
ASKER CERTIFIED SOLUTION
Avatar of bhagyesht
bhagyesht
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mayank S
Converting that to VB.NET, you can use: Return vbnull and Return str instead of getnull = vbnull and getnull = str.

Mayank.
Avatar of omid_krd
omid_krd

Public Function ConvertStr(ByVal str As String) As String
        If IsNothing(str) Then
            ConvertStr = str
        ElseIf str.Length = 0 Then
            ConvertStr = Nothing
        Else
            ConvertStr = str
        End If
    End Function
Accept bhagyesht's comment as answer.
Thanks mayankeagle      

Bhagyesh Trivedi