Checking for Alpha Character

NigelRocks used Ask the Experts™
What's the best way to check a string and/or charcter for whether its alpha in VB.NET?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Public Function IsAlpha(ByVal Value As Char) As Boolean
        Return Char.IsLetter(Value)
    End Function

Open in new window

If you mean it contains any character you can just do a
InStr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", yourstring)
If it returns true an alpha character is there.
yourstring can also be a char.
Also if you need to check for any special characters as well all you have to do is add it in the comparison string.
Of course if you only need alpha the response egl1044 wrote while i was typing will work. Mine is more helpfull when you might need things like !@#$%^&*

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial