Link to home
Start Free TrialLog in
Avatar of adamtrask
adamtrask

asked on

How to convert the text value of a textBox into date

Hi,

I have a textBox which contains in its text property a date. I need to place the date into a date variable: I tried without success the following:

Dim newDate As Date = CType(txtNewDate.Text, Date).ToShortDateString

Can you help?

thanks
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Hi try:
Dim newDate As Date = DateTime.Parse(txtNewDate.Text)

Then you can use newDate.ToShortDateString()
Or directly DateTime.Parse(txtNewDate.Text).ToShortDateString()
ASKER CERTIFIED SOLUTION
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adamtrask
adamtrask

ASKER

Thank you