Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinguishing Letter Characters

Status
Not open for further replies.

ooch1

MIS
Nov 4, 2003
190
GB
Hello,

I have a set of post codes, but i'm only interested in the first letter characters. Obviously with post codes this could relate to either 1,2 or 3 letter characters.

Basically, does anyone know a function or a technique that distinguishes between letter and number characters???

OOch
 
The "IsNumeric" function returns True of each character in its calling argument is in the range "0"-"9" and False otherwise.
 
Golom - Thanks for the response, but how would i use this function when trying to obtain the folowing results:

Original: Required:
a1 1ef a
ab1 2gh ab
abc22 3ij abc

OOch
 
You probably need to write a function in a module and invoke it in your SQL. Something like this.
Code:
Public Function AlphaPart ( Fld As String ) As String
    Dim n As Integer
    For n = 1 To Len(Fld)
        If NOT IsNumeric(Mid$(Fld,n,1)) Then
            AlphaPart = AlphaPart & Mid$(Fld,n,1)
        Else
            Exit For
        End If
    Next n
End Function
And in your SQL
Code:
    Select AlphaPart ( PostCode ) As AlphaCode, ...
    From Tbl ...
    etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top