VarFormat function (oleauto.h)

Formats a variant into string form by parsing a format string.

Syntax

HRESULT VarFormat(
  [in]           LPVARIANT pvarIn,
  [in, optional] LPOLESTR  pstrFormat,
  [in]           int       iFirstDay,
  [in]           int       iFirstWeek,
  [in]           ULONG     dwFlags,
  [out]          BSTR      *pbstrOut
);

Parameters

[in] pvarIn

The variant.

[in, optional] pstrFormat

The format string. For example "mm-dd-yy".

[in] iFirstDay

First day of the week.

Value Meaning
0
The system default
1
Monday
2
Tuesday
3
Wednesday
4
Thursday
5
Friday
6
Saturday
7
Sunday

[in] iFirstWeek

First week of the year.

Value Meaning
0
The system default.
1
The first week contains January 1st.
2
The larger half (four days) of the first week is in the current year.
3
The first week has seven days.

[in] dwFlags

Flags that control the formatting process. The only flags that can be set are VAR_CALENDAR_HIJRI or VAR_FORMAT_NOSUBSTITUTE.

[out] pbstrOut

The formatted string that represents the variant.

Return value

This function can return one of these values.

Return code Description
S_OK
Success.
E_INVALIDARG
One or more of the arguments is not valid.

Remarks

This function uses the user's default locale while calling VarTokenizeFormatString and VarFormatFromTokens.

Requirements

Requirement Value
Target Platform Windows
Header oleauto.h
Library OleAut32.lib
DLL OleAut32.dll

See also

Formatting Routines

VarFormatFromTokens

VarTokenizeFormatString