[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.NET 2005, Get DateTime Calendar Formated Date Value

Posted on 2007-08-01
3
Medium Priority
?
2,531 Views
Last Modified: 2013-11-26
In Visual Studio 2005 using vb.net I have a dropdown calendar on a  particular form.  When a button is clicked i know how to get the calendars day, month and year.

This can be done to assign to a variable like so,

dim somevariable as string
somevariable = dtcalendar.value.day

Obviously we can do dtcalendar.value.month etc.

How can I in one line assign the dtcalendar's entire selected value but format the date.

What im trying to acheive is soemthing like so, just dont know how to do it

somevariable = dtcalendar.value.day + dtcalendar.value.month + dtcalendar.value.year.

I assume that there must be some way to grab the calendars selected date value and format it to DD-MM-YYYY so that I can just take that value straight to a variable?

Thanks in advance.
0
Comment
Question by:superlative
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 19606845
If you are using a datetimepicker:

Dim DateX As Date = Me.DateTimePicker1.Text

Me.txtStart.Text = Format(DateX, "ddMMyyyy")
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 750 total points
ID: 19606858
or

MsgBox (Me.DateTimePicker1.Value.ToString("d-MM-yyyy"))
0
 
LVL 13

Expert Comment

by:dungla
ID: 19606894
Dim strDate As String
strDate = Calendar1.SelectedDate.ToString("dd-MM-yyyy")
Response.Write(strDate)
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

834 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