Solved

Converting empty strings to Null

Posted on 2003-12-08
7
416 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Simple Linear Regression
Starting up a Project

688 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