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

adding asp variables

Status
Not open for further replies.

PeteCan

Programmer
Jan 15, 2002
60
GB
First the code:

Do while Not objRS.EOF
If Count=1 Then
ResValue=objRs.Fields("ResTime").Value
ResCount=ResCount+Resvalue
End if
iRecordCount=iRecordCount+1
objRS.MoveNext
Loop

What I am attempting to do is loop through my database extracting the value for ResTime for each record, and adding the new value to the existing value so at the end I end up with a total figure.
BUT I CAN'T GET THIS TO WORK.

It just seems to concanenate the variable so if record 1=12 when it runs through to record 2, which say has a value of 15, it gives you 1215 instead of the sum of the two values, i.e. 27.

I'm sure it's something simple but can't work it out
 
Try converting your value to an integer:
Code:
 ResValue=cInt(objRs.Fields("ResTime").Value)
Eight now it is treating it like a string which is why it is concatenating rather than adding.
-Tarwn "Customer Support is an art not a service" - marketing saying
"So are most other forms of torture" - programmers response
(The Wiz Biz - Rick Cook)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top