在vb.net中需要有关浮点数的帮助 [英] need help in vb.net about float number

查看:162
本文介绍了在vb.net中需要有关浮点数的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在使用vb.net 2008构建一个下载器,所有东西都运行良好

但我的问题是当我尝试以MB显示文件大小我不能显示点之前的位数,例如我想在结果中的点之前仅显示4位数作为3.1234而不是3.12345677

我在项目中用于将字节转换为MB的代码如下:

 Label1.Text =((e.TotalBytesToReceive /  1024 )/  1024 )&   MB 





希望有人会帮助我..提前感谢:)

解决方案

尝试格式化这样的金额;

< pre lang =vb> Label1.Text = 字符串 .Format( {0:###,## 0.0000} MB,(e.TotalBytesToReceive / 1024 0 )/ 1024 0 ))





希望这会有所帮助,

Fredrik


感谢所有人试图帮助我..解决方案代码:

 Label1.Text = 字符串 .Format(  {0},(((e.TotalBytesToReceive /  1024 )/  1024 ))。ToString(  F04))&   MB 





:)感谢@wes Aday并感谢@Fredrik Bornander尝试帮助我:)


Hi all , i'm building a downloader using vb.net 2008 , all things is working good
but what my problem is when i try to show the file size in MB i can't show the number of digits before the dot , for example i want to show only 4 digits before the dot in the result as 3.1234 and not as 3.12345677
the code i use to convert bytes to MB in my project is as :

Label1.Text = ((e.TotalBytesToReceive / 1024) / 1024) & "MB"



hope some one will help me .. thanks in advance :)

解决方案

Try formatting the amount like this;

Label1.Text = String.Format("{0:###,##0.0000}MB", (e.TotalBytesToReceive / 1024.0) / 1024.0))



Hope this helps,
Fredrik


thanks for all for trying to help me .. the solution code :

Label1.Text = String.Format("{0}", (((e.TotalBytesToReceive / 1024) / 1024)).ToString("F04")) & "MB"



:) thanks @wes Aday and thanks @Fredrik Bornander for trying helping me :)


这篇关于在vb.net中需要有关浮点数的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆