/    Sign up×
Community /Pin to ProfileBookmark

Gotta be a better way to write this ASP code.

Please help. I know that there has to be a better way to write the following code in ASP:

if (cFirstMonth==’January’){nFirstMonth=0;}
if (cFirstMonth==’February’){nFirstMonth=1;}
if (cFirstMonth==’March’){nFirstMonth=2;}
if (cFirstMonth==’April’){nFirstMonth=3;}
if (cFirstMonth==’May’){nFirstMonth=4;}
if (cFirstMonth==’June’){nFirstMonth=5;}
if (cFirstMonth==’July’){nFirstMonth=6;}
if (cFirstMonth==’August’){nFirstMonth=7;}
if (cFirstMonth==’September’){nFirstMonth=8;}
if (cFirstMonth==’October’){nFirstMonth=9;}
if (cFirstMonth==’November’){nFirstMonth=10;}
if (cFirstMonth==’December’){nFirstMonth=11;}

Will

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Jan 31.2003 — I would have created an array of months

then loop through the array and asign the array index value to

cFirstMonth = n;

if it matches tha value just like one of your if statements.


Khalid
×

Success!

Help @Will192 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...