Solved

Converting empty strings to Null

Posted on 2003-12-08
7
414 Views
Last Modified: 2010-08-05
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
Comment
Question by:tyy8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 41

Expert Comment

by:graye
ID: 9898562
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
 
LVL 9

Accepted Solution

by:
bhagyesht earned 50 total points
ID: 9902057
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 9902293
Converting that to VB.NET, you can use: Return vbnull and Return str instead of getnull = vbnull and getnull = str.

Mayank.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:omid_krd
ID: 10061903
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 10319072
Accept bhagyesht's comment as answer.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 10319692
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question