Results 1 to 3 of 3

Thread: [RESOLVED] Case Statement ignore capitals

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Resolved [RESOLVED] Case Statement ignore capitals

    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?

  2. #2
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    Re: Case Statement ignore capitals

    Hi, just convert the whole string to upercase or lower case

    VB Code:
    1. select case month.text.toupper
    2.     case "JANUARY"
    3. '...
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: Case Statement ignore capitals

    Quote Originally Posted by josep
    Hi, just convert the whole string to upercase or lower case

    VB Code:
    1. select case month.text.toupper
    2.     case "JANUARY"
    3. '...
    Thanks Josep, that worked well!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width