Looking into the column

# Thread: Looking into the column

1. Senior Member
Join Date
Dec 1969
Posts
425

## Looking into the column

hi there <BR><BR>I want to look up a column for postcodes the qrystr is "TN35 1SY"<BR><BR>I chop this down to "TN" and using "LIKE &#039;%" & qrystr & "%&#039; it&#039;ll find the right postcode - however<BR><BR>if the qrystr = "B31 7SY"<BR>it finds everything with a "B" in it<BR><BR>how do you tell the sql to look only for the first two letters?

2. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: Looking into the column

"LIKE &#039;" & qrystr & "%&#039;

3. Senior Member
Join Date
Dec 1969
Posts
425

## RE: Looking into the column

Yeah - just looked it up on devguru - doh!<BR><BR>Thanks anyway

4. Senior Member
Join Date
Dec 1969
Posts
425

## how many alph in string?

Is there some code to see how many alpha letters are in a string? as TN33 would return 2 and T22 would return 1?

5. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: how many alph in string?

It can be done I think!!!!<BR><BR>What Database are you using?

6. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: how many alph in string?

No, but you could write some.<BR><BR>For loop, from 1 to Len(myString).<BR><BR>Check the Asc() value of each character... Something like<BR><BR>Function CountAlpha(ByVal sString)<BR> Dim intCounter, intReturn, strChar<BR> intReturn = 0<BR> For intCounter = 1 To Len(sString)<BR> strChar = Mid(sString, intCounter, 1)<BR> If Asc(strChar) &#060; Asc("Z") AND Asc(strChar) &#062; Asc("A") Then<BR> intReturn = intReturn + 1<BR> End If<BR> Next<BR> CountAlpha = intReturn<BR>End Function<BR><BR>Obvioulsly, modify that for your exact needs (what if they enter their postcode in lower-case?).<BR><BR>Craig.

7. Senior Member
Join Date
Dec 1969
Posts
425

## RE: how many alph in string?

Thanks i got there in the end<BR><BR><BR> dim i :: i = 0<BR> dim start :: start = 1<BR> while start &#060;= len(shortcode)<BR> if Asc(UCase(Mid(shortcode,start,1))) &#060; Asc("A") or Asc(UCase(Mid(shortcode,start,1))) &#062; Asc("Z") then _<BR> i = i + 1<BR> start = start + 1<BR> wend<BR> i = ((len(shortcode)-i)*1)<BR>response.Write(left(shortcode,i))<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•