The FormatDateTime function returns a formatted string representation for a date and/or time. The syntax is:
FormatPercent(expression [, format] )
Where:
expression The numeric expression to format
format A date/time formatting value
Expression Result
FormatDateTime(Now, DateFormat.GeneralDate) 10/01/2008 10:55:06 AM FormatDateTime(Now, DateFormat.LongDate) Thursday, October 1, 2008 FormatDateTime(Now, DateFormat.ShortDate) 10/01/2008 FormatDateTime(Now, DateFormat.LongTime) 10:55:06 AM FormatDateTime(Now, DateFormat.ShortTime) 10:55
This example uses the following code to display value in a TextBox. Private Sub Form1_Load(ByVal sender As System.Object, ByVal _ e As System.EventArgs) Handles MyBase.Load Dim txt As String txt &= "FormatDateTime(Now, DateFormat.GeneralDate) = " _ & FormatDateTime(Now, DateFormat.GeneralDate) & _ vbCrLf txt &= "FormatDateTime(Now, DateFormat.LongDate) = " & _ FormatDateTime(Now, DateFormat.LongDate) & vbCrLf txt &= "FormatDateTime(Now, DateFormat.ShortDate) = " & _ FormatDateTime(Now, DateFormat.ShortDate) & vbCrLf txt &= "FormatDateTime(Now, DateFormat.LongTime) = " & _ FormatDateTime(Now, DateFormat.LongTime) & vbCrLf txt &= "FormatDateTime(Now, DateFormat.ShortTime) = " & _ FormatDateTime(Now, DateFormat.ShortTime) & vbCrLf txtResult.Text = txt txtResult.Select(0, 0) End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|