Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an easy way to convert month to numeric

Status
Not open for further replies.

dennis22

Programmer
Oct 8, 2002
32
Hi!

I am a newbie in VB, I have this combo box populated with month, (January, February, ...). I would like to know if there is an easy way to convert the month into its numeric equivalent. A function maybe? A reverse of the MonthName

Example: x = VBFunction(combo1.text) '"January"
Return : 01

Thanks!
 
Stick the month into a date string and use the Month function:

strMonth = "February"
x = Month("1/" & strMonth & "/2004")

x returns 2

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
If your combo holds all the months Jan..Dec, and the style is set so that the user can not type into it, then

x = combo1.listindex + 1

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top