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