感恩快乐字体图片:请教ASP问题?

来源:百度文库 编辑:中科新闻网 时间:2024/05/01 13:36:43
怎样判断这个数字是正数还是负数?
一楼的不吹不行吗?

dim num '定义变量
'判断num 是否大于等于0,如是就是正数,否则相反

if num>=0 then
response.write("是正数")
else
response.write("是负数")
endif

if num>=0 then
response.write("是正数")
else
response.write("是负数")
endif

用函数写吧,方便多次用.
function num_sub(num)
dim num
if num>=0 then
num_sub="正数"
else
num_sub="负数"
end if
end function

function num_sub(num)
rem 这里不能有dim num,否则参数无法再被调用
rem 错了,0不是正数if num>=0 then
if num>0 then
num_sub="正数"
elseif num<0
num_sub="负数"
else
num_sub="零"
end if
end function

if num >0 then