Returns a String value containing the name of the specified month.
Public Function MonthName( _ ByVal Month As Integer, _ Optional ByVal Abbreviate As Boolean = False _ ) As String
Exception type | Error number | Condition |
---|---|---|
5 | Month is less than 1 or greater than 13. |
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.
If Month is less than 1 or more than 13, an ArgumentException error occurs.
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.
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 MyMonth As Integer Dim Name As String MyMonth = 4 Name = MonthName(MyMonth, True) ' "True" returns an abbreviated name. Msgbox(Name) ' Name contains "Apr".
WeekdayName Function |