在VB.NET中将货币转换为十进制 [英] Convert currency to decimal in VB.NET

查看:34
本文介绍了在VB.NET中将货币转换为十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将货币格式的文本转换为十进制格式.

I need to convert text in currency format to decimal format.

示例:12,500.50 美元 -> 12500.50

Example: US$12,500.50 -> 12500.50

该文本在文本框中.我使用了 formatCurrency() 函数,但我需要获取原始文本(十进制格式).

That text is into a textbox. I used the formatCurrency() function, but I need to get the original text (decimal format).

我该怎么做?

推荐答案

我不确定这个,但你可以试一试:

I don't know for sure about this, but you can give it a try:

Dim NewString As String = Replace(Replace(TextBox1.Text, "US$", ""), ",", "")
Dim Currency As Decimal = CDec(NewString)

'Just to check if it works.
MessageBox.Show(Currency)

这篇关于在VB.NET中将货币转换为十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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