• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Enumeration for months?

Hi all, I'm trying to convert a string value selected from a drop down control to a numeric value and having trouble.  List of values are the months, spelled out (January, February,...).  When the user selects one of these, I want to be able to convert this TimeFrame.SelectedValue to an int, January = 1, Feb =2....   integer variable is monthstart.

I don't have much (ok, any) experience with enumerations, but from what I do understand about the language, this is probably way to go.  How can I make the conversion??

Any help would be appreciated,

Thanks in advanced

0
aaalife
Asked:
aaalife
  • 2
  • 2
1 Solution
 
osmantemizCommented:
first of all you dont have to use enumaration for that kind of thing just do that

TimeFrame.Items.Clear();
TimeFrame.Items.Add("Select Month");
TimeFrame.Items.Add("January");
TimeFrame.Items.Add("February);
.
.
.
.
.// just add like this
.
.
TimeFrame.Items.Add("December");

Now if you get the TimeFrame.SelectedValue it will return your int :)
0
 
osmantemizCommented:
sorry... Not SelectedValue you should get SelectedIndex ...
0
 
aaalifeAuthor Commented:
i need January to =1, will TimeFrame.SelectedIndex start at 0, so i have to + 1, or does the index start with 1??
0
 
aaalifeAuthor Commented:
never mind, re-read your answer, got it.

thanks
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now