Get month name from integer VB.NET

On January 2, 2009, in Programming, by Mike Hudson

Use this simple VB.NET code to return the name of the month from an integer.
Example: 1 = January ….. 12 = December

1
2
3
4
5
6
7
Private Function GetMonthName(ByVal monthNum As Integer) As String
Try
Dim strDate As New DateTime(1, monthNum, 1)
Return strDate.ToString("MMM")
Catch ex As Exception
End Try
End Function
Tagged with:  
  • I Halligan

    Easier to use:–

    Dim xMonth As String = MonthName(MonthNum)

    MonthName is a builtIn function to VB.net

    • http://www.mikesel.info/ Mike Hudson

      Thanks for that suggestion. :)

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!