Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

MonthName Function

Class

Microsoft.VisualBasic.DateAndTime

Syntax

MonthName(month [, abbreviate])
month (required; Integer)

The ordinal number of the month, from 1 to 12

abbreviate (optional; Boolean)

A flag to indicate if an abbreviated month name should be returned

Return Value

String containing the name of the specified month

Description

Returns the month name of a given month. For example, a month of 1 returns January or (if abbreviate is True) Jan.

Rules at a Glance

The default value for abbreviate is False.

Example

Public Function GetMonthName(dat As Date) As String

Dim iMonth As Integer = Month(dat)
GetMonthName = MonthName(iMonth)

End Function

Programming Tips and Gotchas

  • month must be an integer; it cannot be a date. Use DatePart("m", dateval ) to obtain a month number from a date.

  • If month has a fractional portion, it is rounded before calling the MonthName function.

  • MonthName with abbreviate set to False is the equivalent of Format(dateval, "mmmm").

  • MonthName with abbreviate set to True is the equivalent of Format(dateval, "mmm").

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata