Determining Length of a string (1 Viewer)

krieb

New member
Local time
Today, 10:40
Joined
Jan 22, 2000
Messages
9
I should state before asking this question, that I do not have any VB experience. I have a field called Sequence and another field called length. The user inputs the sequence information, example ATGCATCAT. I would like the length of this string to be determined and have that information populate the length field. I also have another field called GC content that again, once the length of the sequence is determined I would like it populated. In other words I would like to know the number of G's and C's in the sequence supplied by the user. I believe this may require a IF THEN or CASE SELECT statement? Any help would be greatly appreciated!
 

dennyryan

Registered User.
Local time
Today, 10:40
Joined
Dec 21, 1999
Messages
45
This looks like you're involved in the human genome project. Perhaps you'll uncover an Access gene.

to fill the length field, use code in the AfterUpdate Event for the field where you're entering the content:

me.LengthField = len(me.ContentField)

The other problem is a little more challenging, at least given my knowledge.

The way I would do it is set up a loop in the same AfterUpdate event proedure as above:

dim intLength as integer
dim x as integer
dim intGCount as integer
dim intGLocation

intGCount = 0
for x = 1 to intLength
intGLocation = instr(x,me.ContentField,"G")
if intGlocation > 0 then
intGCount = intGCount + 1
x = intGLocation
end if
next x

me.GCountField = intGCount

you would need to replicate the logic for getting the count of the number of C occurrences as well. However, I would test this pretty thorougly before doing that. I believe that this general approach should work but I'm not completely sure that I have all the synatx right.

Denny
 

Users who are viewing this thread

Top Bottom