VBFormat

Top  Previous  Next

Method

vbFormat(dtInput, strFormatMask)

Parameters

dtInput - A date, or character, or number.

strFormatMask (String - The Format$() mask)

Returns

String

Example

sDateString = oUTILITIES.VBFormat(Now, "dd mmm yyyy hh:nn:ss AMPM")

 

 

Is a simple wrapper for the MS Visual Basic Format() function.

 

FROM VB HELP

 

Returns a Variant (String) containing an expression formatted according to instructions contained in a format expression.

Syntax

Format(expression[, format[, firstdayofweek[, firstweekofyear]]])

The Format function syntax has these parts:

Part

Description

expression

Required. Any valid expression.

format

Optional. A valid named or user-defined format expression.

firstdayofweek

**NOT USED IN the VBFORMAT function

firstweekofyear

**NOT USED IN the VBFORMAT function

Settings

Remarks

To Format

Do This

Numbers

Use predefined named numeric formats or create user-defined numeric formats.

Dates and times

Use predefined named date/time formats or create user-defined date/time formats.

Date and time serial numbers

Use date and time formats or numeric formats.

Strings

Create your own user-defined string formats.

If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format dont include a leading space reserved for the sign of the value; those converted using Str retain the leading space.

If you are formatting a non-localized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.

Note If the Calendar property setting is Gregorian and format specifies date formatting, the supplied expression must be Gregorian. If the Visual Basic Calendar property setting is Hijri, the supplied expression must be Hijri.

If the calendar is Gregorian, the meaning of format expression symbols is unchanged. If the calendar is Hijri, all date format symbols (for example, dddd, mmmm, yyyy) have the same meaning but apply to the Hijri calendar. Format symbols remain in English; symbols that result in text display (for example, AM and PM) display the string (English or Arabic) associated with that symbol. The range of certain symbols changes when the calendar is Hijri.

Symbol

Range

d

1-30

dd

1-30

ww

1-51

mmm

Displays full month names (Hijri month names have no abbreviations).

y

1-355

yyyy

100-9666