Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Converting empty strings to Null

Posted on 2003-12-08
7
Medium Priority
?
421 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 150 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
Technology Partners: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Loops Section Overview

597 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