Case statement, ignore capitals

obscuregirl

Member
Joined
Sep 13, 2006
Messages
15
Location
UK
Programming Experience
Beginner
Hi
I'm trying to add some validation to a text field in which the user is supposed to enter a month name. I'm wanting to check that the input is equal to one of the months of the year. I thought I could do a case statement e.g.
Select Case month.Text
Case "January"
etc........
However, it is possible that the user would enter "january" rather than "January". Is there any way that I can check the input and ignore the case so that I don't have to double the length of the select statement by putting in each month with and without a capital letter?
 
SELECT CASE UCASE(month.text)
CASE IS ="JANUARY"
'Do stuff here for jan
CASE IS = "FEBRUARY"
'Do the feb gear here.
END SELECT
 
or:
VB.NET:
Select Case Month.Text.ToLower()
  Case "januaray"
  Case "february"
End Select

Select Case Month.Text.ToUpper()
  Case "JANUARY"
  Case "FEBRUARY"
End Select
 
One would think so, since it only modifies its own class instance and return result, unlike the utility functions that creates and passes extra new instances as parameters.

(Edit: it's also in the name of good OOP to use the classes own methods for a string instance instead of going walkabout)
 
Back
Top