Simplifying select case statement

In the below select case statement I am checking to see if the character in a string is alphabetic.
Select Case char
     Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
          Do something
End Select

Open in new window

What I would like to know is if there is a simpler way of doing this, like:
case "a" to "z"
if char="a" to "z"
Who is Participating?
Robert SchuttConnect With a Mentor Software EngineerCommented:
Actually, your own first suggestion is perfectly valid:
Select Case [char]
     Case "a" To "z"
          'Do something
End Select

Open in new window

However, there is a more generic way to do this and it includes letters with accents and the likes so not just "a" to "z" but also "é" for example:
     Dim [char] As Char = TextBox1.Text.Substring(0, 1).ToLower()
     If Char.IsLetter([char]) Then
          ' ...
     End If

Open in new window

Note that I used [char] to make it a valid variable name from your code example, and "Char.IsLetter" refers to a static method in the Char class.
duncanb7Connect With a Mentor Commented:
Just example  and partial code only, you can change e.KeyChar for your char or method variable

Hope understand your question completely. If not , please pt it out


Dim KeyAscii As Integer
        KeyAscii = Asc(e.KeyChar)
        Select Case KeyAscii
case 65 to 90    ''for capital ALPHABET A-Z
case 97  to 122    'lower case a-z
case else

Open in new window

All Courses

From novice to tech pro — start learning today.