format date as dd-mmm-yyyy

Joined
Jan 21, 2008
Messages
13
Programming Experience
Beginner
hi

i can format date as Format(Date,"dd-mmm-yyyy") in Vb 6.0
but i cann't do it in Visual Studio 2005(Vb.net)

can anyone tell me the proper way/code for it

thanks in advance

Pallavi
 
Put this in a sub:
VB.NET:
        Dim TS1 As String = DateTime.Now.Day
        Dim TS2 As String = DateTime.Now.Month
        Dim TS3 As String = DateTime.Now.Year
        MsgBox(TS1 & "-" & TS2 & "-" & TS3)
 
In .NET a lower case m is for minutes and an upper case M is for months. Don't use the Format function. Call String.Format where appropriate but in case like this just call ToString on the value itself, e.g.
VB.NET:
MessageBox.Show(String.Format("Today's date is {0:dd-MMM-yyyy}", Date.Now))
MessageBox.Show(Date.Now.ToString("dd-MMM-yyyy"), "Today's date is...")
 
Back
Top