解决"ASP显示Access里的小数时丢失小数点前面的0"
来源:
互联网
日期:2010-10-1
| Tc711Com提示:解决"ASP显示Access里的小数时丢失小数点前面的0" | 比如我们在表单填入0.36,但保存后显示出来的却是.36
有2中解决方法:
法1:
在"控制面版"---"区域和语言选项"--"区域选项"---"自定义"---"数字"---"零起始显示"中选择0.xx
法2:
如果在做了法1之后还不行,就需要在程序里处理:
if DataValue<1 then if left(DataValue,1)<>"0" then DataValue="0"&DataValue end if end if
--------------------------------------------------------
其实还有种情况可能会同时出现,那就是你填的是1.30,但在asp里只显示1.3,如果必须要显示1.30,可以这样做:
''小数点后不足2位的,自动补0 if len(DataValue)-instr(DataValue,".")<2 then DataValue=formatNumber(DataValue,2,-1) end if
综合上面2种问题,整合解决方法:
if int(DataValue)<>DataValue then ''小数点后不足2位的,自动补0 if len(DataValue)-instr(DataValue,".")<2 then DataValue=formatNumber(DataValue,2,-1) end if
''小数点前没有0的小数补0 if DataValue<1 then if left(DataValue,1)<>"0" then DataValue="0"&DataValue end if end if end if
更多的解决"ASP显示Access里的小数时丢失小数点前面的0"请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2010-10-1
|
|
|