Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter
Checking if a value is a letter Checking if a value is a letter
Checking if a value is a letter
Go Back  Xtreme Visual Basic Talk > > > Checking if a value is a letter


Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2005, 01:58 PM
Griz Griz is offline
Newcomer
 
Join Date: Aug 2005
Posts: 9
Default Checking if a value is a letter


I'm trying to figure out if there is an easy solution to see if each character in a string is in the alphabet. In the past I've created an array and added each letter of the alphabet and checked it that way. I'm just curious if there is an easier way?
Reply With Quote
  #2  
Old 10-19-2005, 02:10 PM
anthony_n's Avatar
anthony_n anthony_n is offline
Senior Contributor
 
Join Date: May 2005
Location: Manchester,England
Posts: 1,293
Default

can always just use a regexp

RE.patten = "[A-Za-z]"
or
RE.patten = "\w*"


then comp the length
Reply With Quote
  #3  
Old 10-20-2005, 01:31 AM
gigemboy's Avatar
gigemboy gigemboy is offline
Centurion
 
Join Date: Oct 2005
Location: College Station, TX
Posts: 156
Default

Heres code to evaluate each letter in the text to make sure it falls in between the correct ascii values of a letter...
Code:
Dim I As Integer Do Until I = Len(TextBox1.Text) If (Asc(Strings.Mid(TextBox1.Text.ToLower, I + 1, 1))) > 96 And Asc(Strings.Mid(TextBox1.Text.ToLower, I + 1, 1)) < 123 Then 'Do Nothing Else MsgBox("Not all letters!") Exit Do End If I = I + 1 Loop
__________________
NOTE: My code will usually get the job done, but it is not the prettiest. If you see of a way to make it more efficient or to look more elegant, please feel free to comment on it :) Im still learning...
Reply With Quote
  #4  
Old 10-20-2005, 06:31 AM
abwindsor abwindsor is offline
Newcomer
 
Join Date: Oct 2005
Location: Windsor, Ontario, Canada
Posts: 19
Default

Try Char.IsLetter()?
Reply With Quote
  #5  
Old 10-20-2005, 06:47 AM
Griz Griz is offline
Newcomer
 
Join Date: Aug 2005
Posts: 9
Default

Thanks everyone.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter Checking if a value is a letter
Checking if a value is a letter
Checking if a value is a letter
 
Checking if a value is a letter
Checking if a value is a letter
 
-->