Solved

Converting empty strings to Null

Posted on 2003-12-08
7
412 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
7 Comments
 
LVL 41

Expert Comment

by:graye
Comment Utility
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
Comment Utility
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:mayankeagle
Comment Utility
Converting that to VB.NET, you can use: Return vbnull and Return str instead of getnull = vbnull and getnull = str.

Mayank.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:omid_krd
Comment Utility
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:mayankeagle
Comment Utility
Accept bhagyesht's comment as answer.
0
 
LVL 9

Expert Comment

by:bhagyesht
Comment Utility
Thanks mayankeagle      

Bhagyesh Trivedi
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now