How to stop Date/Time field from showing TIME

I have an access database with a Date/Time field.
When I send the Date/Time field to my lblBirthDate it shows the date thats in the field....but then it shows "12:00:00 AM".

So I want to strip off the 12:00:00 AM part so I used the code below...the problem is that when the form loads the lblBirthDate is empty and my Constructor code is cant run with no date, so the form won't load. I tried "If lblBirthDate = "" Then exit sub Else run code" but then the form loads but my constructor code never runs.

How can I load a record after Form_Load, and fill in lblBirthDate,  but not have the time.
 
 -----------CODE----------------CODE----------------CODE-------------
'Add this code in the constructor of the form
public sub new
  AddHandler label1.DataBindings("Text").Format, AddressOf DateToString
end sub

 ' Handles the Format event for the date
Protected Sub DateToString(ByVal sender As Object, ByVal e As ConvertEventArgs)
        ' You could use either of the following to convert to the proper date
        ' format:
        'e.Value = CType(e.Value, DateTime).ToString("mm/dd/yyyy")
        e.Value = CType(e.Value, DateTime).ToShortDateString
    End Sub
 
LVL 1
Matrix1000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
dim s as s tring
s = Format(e.Value, "MM/dd/yyyy").ToString
e.Value = s
0
Matrix1000Author Commented:
Where would I add that?  
0
Matrix1000Author Commented:
When I add it at the bottom of my DatabaseSearch() sub it underlines " e.Value" saying "Value not a member of System.EventArgs"
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

DotNetLover_BaanCommented:
Hi there,
replace this line >> e.Value = CType(e.Value, DateTime).ToShortDateString << with
e.Value = CType(e.Value, Date).ToShortDateString
-Baan
0
Matrix1000Author Commented:
-Baan

Thanks! but the form still wont load at first....I get an errror highlighting
"AddHandler label1.DataBindings("Text").Format, AddressOf DateToString"

Error: Additional information: Object reference not set to an instance of an object.

---------CONSTRUCTOR CODE AT THE TOP OF MY CODE-------------------

 Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        'THIS AddHandler FORMATS MY DATE BOXES TO STRIP OFF THE TIME '12:00:00AM
        AddHandler lblBirthDate.DataBindings("Text").Format, AddressOf DateToString

    End Sub
----------------------------------------------------------
Is it because there is no date in the lblBirthDate yet while the form loads?
0
davidrichardsonCommented:
i had big probles with a date/time field, in the end i converted it text which solved all my problems
0
AmanBrarCommented:
Hi, try using this -
Dim mytime = Format(Now.Date, "mm/dd/yyyy")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.