Click here to Skip to main content
12,951,034 members (57,465 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 19 Jun 2005

Validating Alphabets

, 19 Jun 2005
Rate this:
Please Sign up or sign in to vote.
The function to validate whether the input is in alphabets or not.


The purpose of writing this article is to share my knowledge with others. In this article, I have written the code for checking the alphabets.


Though this is very basic level code but sometimes we need to include this type of code, in our applications. We can use this code where the entries should be in alphabets like ‘First Name’, ‘Last Name’, etc.


The variable is passed as “C_S” as a parameter to the function named “Check_Alphabets”. There are two variables in the function:

  • Var_Loop
  • Var_Len

Var_Loop is for the looping purpose whereas Var_Len contains the length of “C_S”. Next, the contents in the C_S are being converted to small case by using the LCase function. Next each character in the C_S is being checked in the “For Next” loop. If any character in C_S is not in the range of 97 – 122 ASCII characters then the function returns false. 97 is the ASCII of ‘a’ whereas 122 is the ASCII of ‘z’. If all the characters are in the range of 97 – 122 ASCII characters then the function returns true.

Source Code

Note: Please download source file for proper functioning of the code.

Sub Btn_Submit_OnClick(Sender As Object, E As EventArgs)
  Dim Var_Txt_Text As String
  Var_Txt_Text = Trim(Txt_Text.Text)
  If Var_Txt_Text = "" Then
   Lbl_Message.Text = "Please enter something in the text box."
   Exit Sub
  ElseIf Check_Alphabets(Var_Txt_Text) = True Then
   Lbl_Message.Text = "Congratulations! Input is in alphabets."
   Lbl_Message.Text = "Sorry! Input is not in alphabets."
  End If
 End Sub
 Function Check_Alphabets(C_S)
  Dim Var_Loop, Var_Len
  Var_Len = Len(C_S)
  C_S = LCase(C_S)
  For Var_Loop = 1 To Var_Len
   If Mid(C_S, Var_Loop, 1) < Chr(97) Or Mid(C_S, Var_Loop, 1) > Chr(122) Then
    Return False
   End If
  Return True
 End Function


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Pakistan Pakistan
I am a computer science graduate. I have been working in ASP.Net since January 2003.

You may also be interested in...

Comments and Discussions

GeneralAn idea.... Pin
je_gonzalez20-Jun-05 19:31
memberje_gonzalez20-Jun-05 19:31 
GeneralRe: An idea.... Pin
Issa Qandil30-Jun-05 4:35
memberIssa Qandil30-Jun-05 4:35 
QuestionAre you serious? Pin
mav.northwind20-Jun-05 0:29
membermav.northwind20-Jun-05 0:29 
AnswerRe: Are you serious? Pin
kaangonel20-Jun-05 1:34
memberkaangonel20-Jun-05 1:34 
GeneralRe: Are you serious? Pin
mav.northwind20-Jun-05 2:03
membermav.northwind20-Jun-05 2:03 
AnswerRe: Are you serious? Pin
ilikc0de12-Jun-06 12:46
memberilikc0de12-Jun-06 12:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 20 Jun 2005
Article Copyright 2005 by naveedmazhar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid