View Light

Convert Month number to a string of the Month name

In case you need to convert an integer from 1 to 12 to a string containing the corresponding month, use this function. Pass it an int from 1 to 12...

(I haven't added any sanity-checking code - If you pass it anything outside that range, it will return a null string rather than throwing an exception. If you need that, just add a "Case Default" line at the bottom of the function...)

    Private Function MonthToString(ByVal month As Integer) As String
        Select Case month
            Case 1
                Return "January"
            Case 2
                Return "February"
            Case 3
                Return "March"
            Case 4
                Return "April"
            Case 5
                Return "May"
            Case 6
                Return "June"
            Case 7
                Return "July"
            Case 8
                Return "August"
            Case 9
                Return "September"
            Case 10
                Return "October"
            Case 11
                Return "November"
            Case 12
                Return "December"
        End Select
    End Function
Reply
Replies:
Comfortably Anonymous
12/10/2004 3:16:19 PM
Comfortably Anonymous
7/28/2005 12:38:35 PM
Comfortably Anonymous
8/24/2010 7:11:13 PM
11/17/2017 4:01:31 PM
Comfortably Anonymous
9/15/2005 9:08:59 AM
This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those who have expressed a prior interest in receiving the included information for research and educational purposes. For more information go to: http://www.law.cornell.edu/uscode/17/107.shtml . If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.