Solved

Enumeration for months?

Posted on 2006-07-20
4
227 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 500 total points
Comment Utility
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
Comment Utility
sorry... Not SelectedValue you should get SelectedIndex ...
0
 

Author Comment

by:aaalife
Comment Utility
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
Comment Utility
never mind, re-read your answer, got it.

thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now