RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
关于vb.net数值格式化的信息

vb.net 如何用format转换小数成整数

直接用int就可以了。

创新互联建站提供高防物理服务器租用、云服务器、香港服务器、成都服务器托管

int(2310.125)=2310

如果需要自定义格式输出,就要用tostring方法,比如:

2310.231.tostring("0")的结果就是2310。

如果你要去掉个位数,看来只有(2310.231/10).tostring("0")了。

详细的ToString里面的参数,请看MSDN。我查了一下,有,地址是:

vb.net中format的使用

format(常量或变量或表达式, "格式化参数")

0.00% 以百分比显示 小数点后面固定 2 位

1 - 100%

5 - 500%

0.5 - 50%

0.05 - 5%

如何在vb.net控制台程序中格式化输出结果(如图)

Sub Main()

Dim a As Boolean = True, b As Boolean = False

Console.WriteLine(LCase("a="  a  " b="  b))

Console.WriteLine(LCase("true and false = "  (a And b)))

Console.WriteLine(LCase("true and not false = "  (a And Not b)))

Console.WriteLine(LCase("true false or false = "  ((ab) Or b)))

Console.ReadKey()

End Sub

VB.NET格式输出函数format怎么用?

果在格式化数字时没有指定 format,Format 会提供与 Str 函数类似的功能

' 如果没有指定格式,则返回字符串。

MyStr = Format(23) ' 返回 "23"。

' 用户自定义的格式。

MyStr = Format(5459.4, "##,##0。00") ' 返回 "5,459.40"。

MyStr = Format(334。9, "###0。00") ' 返回 "334.90"。

MyStr = Format(5, "0。00%") ' 返回 "500.00%"。

MyStr = Format("HELLO", "") ' 返回 "hello"。

MyStr = Format("This is it", "") ' 返回 "THIS IS IT


文章名称:关于vb.net数值格式化的信息
标题路径:http://sczitong.cn/article/doojpjd.html