明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1984|回复: 4

如何将类似 ".5"数值改为"0.5"显示

[复制链接]
发表于 2002-12-5 18:27 | 显示全部楼层 |阅读模式
发表于 2002-12-6 08:12 | 显示全部楼层

这是我写的一个程序片断,你看是否合适

Private Function f(str As String) As String
If IsNumeric(str) Then
  If Val(str) < 1 And Val(str) > 0 Then f = "0" & Trim(str) Else f = Trim(str)
Else
  f = str
End If
End Function
我曾经这样写上面的函数:
Private Function f(str As String) As String
If Left(str,1)="." And IsNumeric(str) Then f="0" & str Else f=str
End Function
发表于 2002-12-7 18:33 | 显示全部楼层

Re:如何将类似 ".5"数值改为"0.5"显示

在VB中可直接用Format函数。
如:保存小数点后两位,可以用Format(1.23456,".00")=1.23,
如果点号之前补零的话,只要Format(0.23456,"0.00")=0.23。
发表于 2002-12-30 11:14 | 显示全部楼层

用函数"format(aaa,"0.00")"即可

你的方法太复杂,将数字转换成字符串时用函数"format(aaa,"0.00")"即可
发表于 2003-1-23 11:22 | 显示全部楼层

使用format加以格式话

使用format加以格式话
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-3 05:21 , Processed in 0.413869 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表