Return the name of a month????

PaulSpell

Registered User.
Local time
Today, 16:41
Joined
Apr 19, 2002
Messages
201
Other than using a select case statement to calc month names, is there a function that accepts an integer value and returns the name of the corresponding month?
 
What I need to do is pass an integer value to a function that returns the name of the month (i.e. 1=Jan, 2=Feb etc). The above would work fine if I was passing dates, but not integers.

Any ideas?
 
Use the Month() function to get the numeric equivalent.

HTH
RDH
 
Try this little function:
Code:
Function cMon(intMon As Variant) As String
Dim varMon As String
varMon = Str(intMon) & "/" & "00"
cMon = Format(DateValue(varMon), "mmmm")
End Function

to test: ? cmon(12)
returns: December
 
Another way along the lines of raskew

Code:
Public Function GetMonth(ByVal intMonth As Integer) As String

    GetMonth = Left$(Format(CStr(intMonth) & "/" & CStr(intMonth) & "/00", "mmm"), 3)

End Function
Regards
Chris
 
I would use an Array, it`s easier and quicker. Create this Function :-

Public Function FindMonth(MonthNo As Integer)

Dim MyMonths(1 To 12) As String

MyMonths(1) = "JAN"
MyMonths(2) = "FEB"
MyMonths(3) = "MAR"
MyMonths(4) = "APR"
MyMonths(5) = "MAY"
MyMonths(6) = "JUN"
MyMonths(7) = "JUL"
MyMonths(8) = "AUG"
MyMonths(9) = "SEP"
MyMonths(10) = "OCT"
MyMonths(11) = "NOV"
MyMonths(12) = "DEC"

FindMonth = MyMonths(MonthNo)
MsgBox FindMonth

End Function


To call it just do :-

Public Function RunFindMonth(MonthNo As Integer)

FindMonth(7)

End Function
 
Code:
Public Function LongMonth(intMonth as integer) as String
LongMonth=Format(intMonth,"mmmm")
End Function
 

Users who are viewing this thread

Back
Top Bottom