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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count occurences of a letter in text

Status
Not open for further replies.

KenG

Technical User
Mar 20, 2000
67
US
I am starting a new database in a biochemistry lab. I need to count the number of times the letter 'a' or 'g' or 't' or 'c' occur in a sequence of these four letters. I need this information for each record, and then for all the records in the query.<br>
<br>
I've tried using the String function as a criteria and then use Count to get the number of times the letter 'a' appears in the string.<br>
<br>
Thanks in advance,<br>
Ken Graham<br>
<A HREF="mailto:kjgraham@ucdavis.edu">kjgraham@ucdavis.edu</A>
 
I think you are going to need a function.<br>
Which can be called from your query.<br>
the Command word to look at is INSTR<br>
Which finds a String with in another string.<br>
Then put it in a loop<br>
similar to this<br>
-------------------------<br>
Public Function FindLetters(TextLetterIsIn, LetterTofind)<br>
Dim a, NumTimes, Value1 As Integer<br>
NumTimes = 0<br>
For a = 1 To Len(TextLetterIsIn)<br>
Value1 = InStr(a, TextLetterIsIn, LetterTofind)<br>
NumTimes = NumTimes + 1<br>
a = Value1 + 1<br>
Next<br>
FindLetters = NumTimes<br>
End Function<br>
-----------------------------<br>
Now this is going to have to be called once for each letter to search for.<br>
Or you could use this a s straing point and modify it to suit.<br>
Also It is case sensitive. If you wan to find a lower case &quot;a&quot; which is diiferent that a uppercas &quot;A&quot; this function will work.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top