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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Converting that to VB.NET, you can use: Return vbnull and Return str instead of getnull = vbnull and getnull = str.
Mayank.
Mayank.
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
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
Bhagyesh Trivedi