Not quite so simple

M

Mick

Something so simple is not working, I need a hint please.
Im trying to add up some field values with
<%dtcosthiresubtotal=dtcosthireitem1 + dtcosthireitem2 + dtcosthireitem3 %>
if dtcosthireitem1, 2, and 3 have values for example 12,26,34, then
dtcosthiresubtotal shows 122634 in a string rather than adding the values to
a total of 72, any clues please.
 
R

Ronx

Convert the variables to numbers before performing the addition.

First check that the variables are actually numeric values
Convert to numbers
Do the sums

<%
If isnumeric(dtcosthireitem1) and isnumeric(dtcosthireitem2) and
isnumeric(dtcosthireitem3) then
Dtcosthiresubtotal = CDbl(dtcosthireitem1) + CDbl(dtcosthireitem2) +
CDbl(dtcosthireitem3)
Else
'Give an error message
End if
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top