[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

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.
0
tyy8
Asked:
tyy8
1 Solution
 
grayeCommented:
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).
0
 
bhagyeshtCommented:
this is a small function in vb just convert it to vb.net



function getnull(str as string) as string
   if str="" then
       getnull=vbnull
   else
       getnull=str
   end if
end function
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Converting that to VB.NET, you can use: Return vbnull and Return str instead of getnull = vbnull and getnull = str.

Mayank.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
omid_krdCommented:
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
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Accept bhagyesht's comment as answer.
0
 
bhagyeshtCommented:
Thanks mayankeagle      

Bhagyesh Trivedi
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now