-1
A
回答
1
我以前做過一次類似的功能,這是一個很好的一步,讓你開始,你能適應它:
#Region " Money Abbreviation "
' [ Money Abbreviation Function ]
'
' // By Elektro [email protected]
'
' Examples :
'
' MsgBox(Money_Abbreviation(1000)) ' Result: 1 K
' MsgBox(Money_Abbreviation(1000000)) ' Result: 1 M
' MsgBox(Money_Abbreviation(1500000, False)) ' Result: 1,5 M
Private Function Money_Abbreviation(ByVal Quantity As Object, _
Optional ByVal Rounded As Boolean = True) As String
Dim Abbreviation As String = String.Empty
Select Case Quantity.GetType()
Case GetType(Int16), GetType(Int32), GetType(Int64)
Quantity = FormatNumber(Quantity, TriState.False)
Case Else
Quantity = FormatNumber(Quantity, , TriState.False)
End Select
Select Case Quantity.ToString.Count(Function(character As Char) character = Convert.ToChar("."))
Case 0 : Return String.Format("${0}", Quantity)
Case 1 : Abbreviation = "k"
Case 2 : Abbreviation = "M"
Case 3 : Abbreviation = "B"
Case 4 : Abbreviation = "Tr."
Case 5 : Abbreviation = "Quad."
Case 6 : Abbreviation = "Quint."
Case 7 : Abbreviation = "Sext."
Case 8 : Abbreviation = "Sept."
Case Else
Return String.Format("${0}", Quantity)
End Select
Return IIf(Rounded, _
String.Format("{0} {1}", StrReverse(StrReverse(Quantity).Substring(StrReverse(Quantity).LastIndexOf(".") + 1)), Abbreviation), _
String.Format("{0} {1}", StrReverse(StrReverse(Quantity).Substring(StrReverse(Quantity).LastIndexOf(".") - 1)), Abbreviation))
End Function
#End Region
相關問題
- 1. JavaScript驗證貨幣金額
- 2. 轉換小數貨幣和背部
- 3. 從LINQ查詢轉換小數貨幣
- 4. 轉換產生貨幣的小數* 3?
- 5. 斯卡拉解析貨幣金額和刪除貨幣符號
- 6. 轉換貨幣
- 7. 需要貨幣符號和金額
- 8. 從格式化金額提取貨幣
- 9. php echo貨幣格式加上金額
- 10. Money Rails - 金額和貨幣的順序
- 11. 轉換爲貨幣格式
- 12. 轉換爲貨幣格式
- 13. C++轉換爲貨幣值
- 14. 將多個發票金額轉換爲一種貨幣的總和
- 15. 轉換貨幣自由浮動(和括號表明負數金額)
- 16. 貨幣對數轉換軌
- 17. 貨幣面額
- 18. 將數字(非貨幣)的值轉換爲文本條目
- 19. Javascript貨幣轉換
- 20. 貨幣轉換 - AngularJS
- 21. Django貨幣轉換
- 22. 貨幣轉換器
- 23. PHP將數字轉換爲貨幣
- 24. javascript將貨幣轉換爲數千
- 25. 將貨幣格式轉換爲數字
- 26. FoxPro將貨幣轉換爲數字
- 27. 將整數轉換爲貨幣
- 28. 如何將貨幣轉換爲數字?
- 29. 貨幣縮寫(EUR,USD,GBP)轉換爲貨幣符號(歐元,美元,英鎊)
- 30. 如何將小數轉換爲WinRT中的任何貨幣?
你有什麼企圖?你嘗試搜索嗎?的 –
可能重複的[在到字數字轉換C#(http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp) –