Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Enumeration for months?

Posted on 2006-07-20
4
Medium Priority
?
239 Views
Last Modified: 2010-04-16
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
Comment
Question by:aaalife
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
osmantemiz earned 2000 total points
ID: 17148033
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
 
LVL 3

Expert Comment

by:osmantemiz
ID: 17148038
sorry... Not SelectedValue you should get SelectedIndex ...
0
 

Author Comment

by:aaalife
ID: 17148116
i need January to =1, will TimeFrame.SelectedIndex start at 0, so i have to + 1, or does the index start with 1??
0
 

Author Comment

by:aaalife
ID: 17148122
never mind, re-read your answer, got it.

thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question