货币格式编号VB.NET [英] Money Format Number VB.NET

查看:153
本文介绍了货币格式编号VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试转换货币格式的数学结果示例:

I'm trying to convert a mathematical result of money format example:

Dim num1 As Integer = 2000
Dim num2 As Integer = 500

msgbox(cDbl(num1 + num2))

它只返回2500,我需要返回我的2,500.00
如果有人有任何想法,我会非常有帮助谢谢。

It only returns 2500, which I need to return my 2,500.00 if anyone has any idea how I would be very helpful thanks.

推荐答案

您的 MsgBox 显示您的价值,但没有格式化,因为您没有要求。

Your MsgBox shows you the value, but it hasn't formatted it, as you haven't asked it to.

如果您进一步了解,并将结果格式化为字符串,您将获得所需的格式,例如:

If you went a little further and formatted the result as a string, you'll get the format you desire, e.g:

Dim num1 As Double = 2000
Dim num2 As Double = 500
Dim sum As Double = num1 + num2

MsgBox(sum.ToString("0.00")) ' Adjust format string to suit

这篇关于货币格式编号VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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