Date And Time
|
Tips >> Visual
Basic |
MAKE WEB APPLICATION WITHOUT KNOWLEDGE OF CODING? CLICK HERE
The basic data type "Date" is used in Visual Basic
to store the "date and time". Date literals are enclosed
within the # operator.
|
Dim birthDate As Date
birthDate = #1/20/1964# |
|
THE FORMAT FUNCTION:
The Format function is used to format dates and numbers.
The actual result is dependent on the country settings on the computer.
The general syntax is:
|
Format(expression, formatExpression) |
|
NAMED NUMBER FORMAT EXPRESSIONS
|
Named Part |
Description
|
General Number |
Number displayed normally, with
no separators. |
Currency |
Number displayed with currency
symbol, thousand separators and decimal places. The actual format
depends on the locale. |
Fixed |
Displays at least one digit
on the left of the decimal point, and two digits to the right
of the point. |
Standard |
Same output as Fixed, but with a thousands separator. |
Percent |
Output is multiplied by 100 and
has a % sign at the front. Displayed with two decimal places. |
Scientific |
Output is displayed as standard scientific (eg.
6.42E+01). |
Yes/No |
Displays No if number is 0,
otherwise displays Yes. |
True/False |
Displays False if number is 0, otherwise displays
True. |
On/Off |
Displays Off if number is 0, otherwise
displays On. |
|
The following example uses the Currency format expression
to print a value according to the country's settings. In the UK,
this would show as £64.20.
|
Debug.Print Format(64.2, "Currency")
|
|
NAMED DATE/TIME FORMAT EXPRESSIONS:
|
Named Part |
Description
|
General Date |
Displays a general date. |
Long Date |
Displays a long date according the system's long
date settings. |
Medium Date |
Displays a medium date according the system's
long date settings. |
Short Date |
Displays a short date according the system's long
date settings. |
Long Time |
Displays a long time according to the system's
long time settings, includes hours, minutes and seconds. |
Medium Time |
Displays the time in 12-hour format with AM/PM
adornments. |
Short Time |
Displays the time in 24-hour format. |
|
|
If you don't find what you are looking for. Please click
here to submit your query, our experts will reply soon.
|