asp几个函数的运算怎么写

来源:百度知道 编辑:UC知道 时间:2024/06/03 04:38:09
比如 表里有几个数据 a b c 然后在显示的时候怎么让a*b*c?让它显示出来

假设a,b,c为字段名,并且都是数字型的:
set rs=conn.execute("select a*b*c From table where id=1")
if not rs.eof then response.write(rs(0));

如果不是数字型的,就要现将里面的数字取出来经行判断,是数字才想乘:
set rs=conn.execute("select a,b,c from table where id=1")
if not rs.eof then
if isnumeric(rs(0)) and isnumeric(rs(1)) and isnumeric(rs(2)) then
response.write(rs(0)*rs(1)*rs(2))
end if
end if

isnumeric用来检查是否是数字,我没去测试能否检测小数,这里你可以用正则表达式来验证

set rs=conn.execute("select a,b,c,a*b*c as d from 表")
do while not rs.eof
response.write rs("d")&"<br>"
rs.MoveNext
loop
%>

select a*b*c From table
table为表名
abc必须是数值字段

取出来显示成绩或者 select a,b,c,a*b*c as d from biao

你说的abc是指的三个字段还是三条记录?