Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

Example: US$12,500.50 -> 12500.50

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

How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
203 views
Welcome To Ask or Share your Answers For Others

1 Answer

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...