แก้ไข

แชร์ผ่าน


DateAndTime.MonthName(Int32, Boolean) Method

Definition

Returns a string value containing the name of the specified month.

public static string MonthName (int Month, bool Abbreviate = false);
static member MonthName : int * bool -> string
Public Function MonthName (Month As Integer, Optional Abbreviate As Boolean = false) As String

Parameters

Month
Int32

Required. The numeric designation of the month, from 1 through 13; 1 indicates January and 12 indicates December. You can use the value 13 with a 13-month calendar. If your system is using a 12-month calendar and Month is 13, MonthName returns an empty string.

Abbreviate
Boolean

Optional. True to abbreviate the month name; otherwise, False. The default is False.

Returns

A string value containing the name of the specified month.

Exceptions

Month is less than 1 or greater than 13.

Examples

This example uses the MonthName function to determine the name of the month, by the integer given. The Boolean value will determine whether the full name (False) or the abbreviated name (True) will be displayed.

Dim thisMonth As Integer
Dim name As String
thisMonth = 4
' Set Abbreviate to True to return an abbreviated name.
name = MonthName(thisMonth, True)
' name now contains "Apr".

Remarks

The string returned by MonthName depends not only on the input arguments, but also on the Regional Options settings specified in the Windows Control Panel.

Note

MonthName uses the current calendar setting from the CurrentCulture property of the CultureInfo class in the System.Globalization namespace. The default CurrentCulture values are determined by Control Panel settings.

Applies to

See also