如何判断当rs为空时 不加入计算表达式?

kkk444dsfsa 2010-07-21 03:07:38
dim dcml,zyf,hkze,zzzfy,zqitafy
dcml = 0
zyf = 0
hkze = 0
zzzfy= 0
zqitafy = 0

if not isnull(rs("zyf")) then zyf = cdbl(rs("zyf"))
if not isnull(rs("clyf")) then clyf =cdbl(rs("clyf"))
if not isnull(rs("hkze")) then hkze = cdbl(rs("hkze"))
if not isnull(rs("zzzfy")) then zzzfy = cdbl(rs("zzzfy"))
if not isnull(rs("zqitafy")) then zqitafy = cdbl(rs("zqitafy"))

dcml = zyf - clyf - hkze - zzzfy - zqitafy
当zzzfy 和zqitafy 在数据库中为空时 后面的计算结果错误

我用<%=dcml%> 怎么不行
...全文
130 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kkk444dsfsa 2010-07-22
[Quote=引用 11 楼 chinmo 的回复:]
zyf = rs("zyf")& "" : if zyf ="" then zyf = 0
clyf = rs("clyf") & "" :if clyf ="" then clyf = 0
hkze = rs("hkze") & "" :if hkze ="" then hkze = 0
zzzfy = rs("zzzfy") & "" :if zzzfy ……
[/Quote]

一语点醒梦中人
回复
zyf = rs("zyf")& "" : if zyf ="" then zyf = 0
clyf = rs("clyf") & "" :if clyf ="" then clyf = 0
hkze = rs("hkze") & "" :if hkze ="" then hkze = 0
zzzfy = rs("zzzfy") & "" :if zzzfy ="" then zzzfy =0
zqitafy = rs("zqitafy") &"" : if zqitafy ="" then zqitafy = 0

dcml = zyf - clyf - hkze - zzzfy - zqitafy
你这个应该放在循环内吧?
回复
zyf=trim(rs("zyf")) : if zyf="" then zyf = 0
clyf =trim(rs("clyf ")) : if clyf ="" then clyf = 0
hkze=trim(rs("hkze")) : if hkze="" then hkze= 0
zzzfy=rs("zzzfy") : if zzzfy="" then zzzfy= 0
zqitafy=trim(rs("zqitafy")) : if zqitafy="" then zqitafy= 0


dcml = zyf - clyf - hkze - zzzfy - zqitafy
回复
kkk444dsfsa 2010-07-21
问题还没解决啊 谁给看看
回复
kkk444dsfsa 2010-07-21
<%
dim dcml,zyf,hkze,zzzfy,zqitafy
dcml = 0

'if not isnull(rs("jianshu")) then hjjs =hjjs + cdbl(rs("jianshu"))

zyf = rs("zyf")& "" : if zyf ="" then zyf = 0
clyf = rs("clyf") & "" :if clyf ="" then clyf = 0
hkze = rs("hkze") & "" :if hkze ="" then hkze = 0
zzzfy = rs("zzzfy") & "" :if zzzfy ="" then zzzfy =0
zqitafy = rs("zqitafy") &"" : if zqitafy ="" then zqitafy = 0

dcml = zyf - clyf - hkze - zzzfy - zqitafy

dim curpage, i
if request("page")="" then
curpage = 1
else
curpage = clng(request("page"))
end if
rs.pagesize = 100000
rs.absolutepage = curpage
for i = 1 to rs.pagesize
%>
<tr onMouseOver="bgColor='#4474bb'" onMouseOut="bgColor='#ffffff'" onDblClick="javascript:window.open('../baobiao/fhqdshxx.asp?fhqdbh=<%=base64Encode(rs("fhqdh"))%>&companyid=<%=base64Encode(newcompanyid)%>','发货清单详细信息','directorys=no,toolbars=no,status=no,menubars=no,scrollbars=yes,resizeable=no,width=1000,height=600,top='+(window.screen.height-600)/2+',left='+(window.screen.width-1000)/2+'');">
<td width="99" height="20"><div align="center"><%=rs("fhqdh")%></div></td>
<td width="89" ><div align="center"><%=rs("kcsj")%></div></td>
<td width="61"><div align="center"><%=rs("fgsbm")%></div></td>
<td width="71"><div align="center"><%=rs("zdzbm") %></div></td>
<td width="80"><div align="center"><%=rs("clbh")%></div></td>
<td width="96"><div align="center"><%=rs("zyf")%></div></td>
<td width="71"><div align="center"><%=rs("clyf")%></div></td>
<td width="80"><div align="center"><%=rs("hkze")%></div></td>
<td width="65"><div align="center"><%=rs("zzzfy")%></div></td>
<td width="84"><div align="center"><%=rs("zqitafy")%></div></td>
<td width="133"><div align="center"><font color="#FF0000"><%=dcml%></font></div></td>
</tr>

<% rs.movenext
if rs.eof then
i = i + 1
exit for
end if
next
%>
回复
SNOYC 2010-07-21
循环写错了吧,代码多贴点上来啊,要不然怎么看问题啊。。
回复
kkk444dsfsa 2010-07-21
第一行的单车毛利是正确的 其他的都错了
回复
toury 2010-07-21
zyf=rs("zyf")&"" : if zyf="" then zyf = 0
clyf =rs("clyf ")&"" : if clyf ="" then clyf = 0
hkze=rs("hkze")&"" : if hkze="" then hkze= 0
zzzfy=rs("zzzfy")&"" : if zzzfy="" then zzzfy= 0
zqitafy=rs("zqitafy")&"": if zqitafy="" then zqitafy= 0


dcml = zyf - clyf - hkze - zzzfy - zqitafy
回复
安安_007 2010-07-21
嗯,这个问题要好好看看了
回复
kkk444dsfsa 2010-07-21
if not isnull(rs("zyf")) and rs("zyf") <>"" then zyf = cdbl(rs("zyf"))
if not isnull(rs("clyf")) and rs("clyf") <>"" then clyf =cdbl(rs("clyf"))
if not isnull(rs("hkze")) and rs("hkze") <>"" then hkze = cdbl(rs("hkze"))
if not isnull(rs("zzzfy")) and rs("zzzfy") <>"" then zzzfy = cdbl(rs("zzzfy"))
if not isnull(rs("zqitafy")) and rs("zqitafy") <>"" then zqitafy = cdbl(rs("zqitafy"))
dcml = zyf - clyf - hkze - zzzfy - zqitafy

换成这样也不行啊
回复
chinaczb2001 2010-07-21
楼主试试用If rs("zzzfy")<>"" And not isnull(rs("zzzfy")) Then zzzfy = cdbl(rs("zzzfy")),而不用
回复
lzp4881 2010-07-21
为空有两种,一种是null,一种是"",两种情况都要考虑到。
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告