MonthName Function (Visual Basic)
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
Required. Integer. 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.
Optional. Boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False, which means the month name is not abbreviated.
|Exception type||Error number||Condition|
Month is less than 1 or greater than 13.
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the.) However, when possible, you should consider replacing such error control with .
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.
MonthName uses the current calendar setting from theproperty of the class in the 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.
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)