6 Replies - 101354 Views - Last Post: 19 November 2009 - 03:19 AM Rate Topic: -----

#1 Rg2005  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 20-September 07

How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Post icon  Posted 01 December 2007 - 03:04 AM

How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.net +asp.net
Is This A Good Question/Topic? 0
  • +

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 01 December 2007 - 05:47 AM

It's all done with your format, for the format you're looking for try something like this, I create a function for my application, in the event I need different display within an application, so my function looks like so:

Public Function ChangeFormat(ByVal dtm As DateTime, ByVal format As String) As String
	Return dtm.ToString(format)
End Function



Then When I use it I call it like so:

TextBox1.Text = ChangeFormat(DateTime.Now,"MM/dd/yyyy")



Try that out and see if that is what you're looking for. Hope it helps :)
Was This Post Helpful? 2

#9 aparichit00  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 1
  • Joined: 13-December 08

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 16 September 2009 - 12:30 AM

View PostRg2005, on 1 Dec, 2007 - 02:04 AM, said:

How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.net +asp.net




hello viewers
if u r giving custom format of datetimepicker property with "dd/MM/yyyy" if u want to convert this format with "MM/dd/yyyy" then it is very simple .
just follow this step
1. create 1 class name is Convert.
2. now enter one function GetDate
hear is source.
Public Shared Function Getmydate(ByVal code As System.String) As String
Dim ldate, ldate1, ldate2, ldate3 As String
ldate = code
ldate1 = Mid(ldate, 1, 2)
ldate2 = Mid(ldate, 4, 2)
ldate3 = Mid(ldate, 7, 4)
ldate = ldate2 & "/" & ldate1 & "/" & ldate3
Return ldate

End Function
3. now use it in u r form
dim date1 as string
date1=Conver.getdate(datetimepicker.text)

bye

This post has been edited by aparichit00: 16 September 2009 - 12:31 AM

Was This Post Helpful? 1

#10 nitinkhadloya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-November 09

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 18 November 2009 - 06:41 AM

try this

first you have to convert textbox valut into date then

dt.tostring("MM/dd/yyyy")

This post has been edited by nitinkhadloya: 18 November 2009 - 06:42 AM

Was This Post Helpful? 0
  • +
  • -

#11 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 18 November 2009 - 06:54 AM

Hi,

Easiest is

TextBox1.Text = Format(CDate("15-01-2009"),"MM/dd/yyyy")


Was This Post Helpful? 0
  • +
  • -

#12 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 18 November 2009 - 10:09 AM

PsychoCoder's code is the simplest if you look closer.
Was This Post Helpful? 0
  • +
  • -

#13 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.

Posted 19 November 2009 - 03:19 AM

Sure but it requires an extra sub...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1