0
A
回答
1
如果你保證DD.MM.YYYY格式的日期,這個VB代碼可能是像你想要的東西。
Function ConvertDate(ByVal date As String) As String
Dim textDate As String = ""
Dim nDay As Integer = CInt(date.Split(".")(0))
Dim nMonth As Integer = CInt(date.Split(".")(1))
Dim nYear As Integer = CInt(date.Split(".")(2))
Dim hundreds As Integer = 0
Dim notHundreds As Integer = 0
//Convert day to text.
Select Case (nDay)
Case 1
textDate += "First"
//Fill in cases 2-30
Case 31
textDate += "Thirty-First"
End Select
//Add your separator.
textDate += " "
//Convert the month to text.
Select Case (nMonth)
Case 1
textDate += "January"
//Finn in cases 2-11
Case 12
textDate += "December"
End Select
//Add your separator.
textDate += " : "
//Split the year.
hundreds = nYear/100
notHundreds = nYear - 100 * hundreds
//Add the hundreds part of the date if there is one.
If hundreds <> 0 Then
textDate += NumberUnder100ToText(hundreds)
textDate += "Hundred "
End If
//Add the not hundreds part if there is one.
If notHundreds <> 0 Then
textDate += NumberUnder100ToText(notHundreds)
End If
//Remove extra trailing space if present.
textDate = textDate.Trim()
Return textDate
End Function
Function NumberUnder100ToText(ByVal number As Integer) As String
Dim text As String = ""
If number < 20 Then
//Covers 1 to 19
Select Case (number)
Case 0 //Do nothing
text = ""
Case 1
text = "One"
//Cases 2-18
Case 19
text = "Nineteen"
End Select
Else
//Add the 10s place
Select Case (number/10)
Case 2
text = "Twenty"
//Cases 3-8
Case 9
text = "Ninety"
End Select
//Add the 1s place
If (number Mod 10 <> 0) Then
text += "-"
text += NumberUnder100ToText(number Mod 10)
End If
End If
Return text
End Function
相關問題
- 1. 在RDLC中將字數轉換爲字
- 2. 如何將數字轉換爲日期
- 3. jquery將數字轉換爲日期?
- 4. 將日期變量轉換爲數字
- 5. SAS:將日期轉換爲數字
- 6. PHP將數字轉換爲日期
- 7. 轉換日期爲數字蟒蛇
- 8. 將數字轉換爲日期
- 9. 將數字轉換爲日期
- 10. SQL Server將數字轉換爲日期
- 11. 將字母轉換爲相應數字
- 12. 將字母轉換爲數字
- 13. 將數字轉換爲字母組合
- 14. 將數字轉換爲字母javascript
- 15. 將數字轉換爲字母
- 16. 將數字轉換爲字母
- 17. 將一串字母轉換爲數字
- 18. 轉換字母與數字
- 19. Python轉換字母數字
- 20. 將字符串轉換爲日期並將日期轉換回字符串
- 21. 將日期字段轉換爲僅日期字段
- 22. 解析日期字符串(字符串轉換爲日期)
- 23. 將整數字符串日期轉換爲實際日期
- 24. 如何將數字日期變量轉換爲季度日期?
- 25. 如何將R日期轉換爲Excel數字序列日期?
- 26. 爲新的日期構造函數轉換字符串日期
- 27. 如何日期字符串轉換爲日期數據類型
- 28. 如何在rdlc中轉換日期
- 29. 轉換數字字符字母字符
- 30. 將日期字符串轉換爲帶日期的ISO日期
不,我認爲你不能輕易做到這一點。您寧願將其轉換爲代碼並傳遞已轉換的參數。 – Pikoh
@Pikoh所以,是否有任何內置的方法的C#將int轉換爲字母? – Brainiac
我知道沒有內置的東西。你可以試試[Humanizer](https://github.com/Humanizr/Humanizer) – Pikoh