Question

Asked:
Asked By:
Nov 21 2008   6:18 AM GMT
AnandaDebnath   240 pts.

vb6.0_MonthNumber_to_MonthName


VB, Visual Basic 6, VB 6, Visual Basic Month Function

Hi Experts

In Visual Basic 6.0
I coded for month name eg. msgbox MonthName(1,True)
Returned as Jan

But I want the Month Number juslike above any code please provide
eg. msgbox MonthNumber(Jan,true)

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



I think there is not a function for that, but you could write one, which would be very simple.

Something like:

Private Function MonthNumber(month As String)
Select Case UCase(month)
Case "JAN"
MonthNumber = 1
Case "FEB"
MonthNumber = 2
Case "MAR"
MonthNumber = 3
...
...
Case Else
MonthNumber = 0
End Select
End Function


If you don't want to write such a function, you could use the the Month function, which takes a date as a parameter, so you could artificially construct a date with you desired month.

For example, if you want the month number for "Apr", you use the Month function like this:

MsgBox Month("Apr" + "-01-2000")
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development.

Looking for relevant Development Whitepapers? Visit the SearchWinDevelopment.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register