字符转换问题.

bo18 2005-10-15 05:01:31
如何将数字字符串转换成中文字符串?
如: 将123456 ----> 一二三四五六
...全文
99 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2005-10-15
  • 打赏
  • 举报
回复
如果数字不含○,可以利用MONTHNAME函数:

Private Sub Command1_Click()
MsgBox trans(987654321)
End Sub
Function trans(ByVal x As Long) As String
Dim i As Integer
trans = x
For i = 1 To 9
trans = Replace(trans, i, Left(MonthName(i), 1))
Next
End Function
northwolves 2005-10-15
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
MsgBox trans(987654321)
End Sub
Function trans(ByVal x As Long) As String
Const s = "○一二三四五六七八九"
Dim i As Integer
trans = x
For i = 0 To 9
trans = Replace(trans, CStr(i), Mid(s, i + 1, 1))
Next
End Function
faysky2 2005-10-15
  • 打赏
  • 举报
回复
这个也可以:
Private Sub Command1_Click()
Dim strTemp As String * 1, i%, x As String, strResult As String, strCmp As String
x = "1234589"
strCmp = "一二三四五六七八九"
For i = 1 To Len(x)
strTemp = Mid(x, i, 1)
strResult = strResult & Mid(strCmp, strTemp, 1)
Next
Debug.Print strResult
End Sub
faysky2 2005-10-15
  • 打赏
  • 举报
回复
只想到了苯方法:
Private Sub Command1_Click()
Dim strTemp As String * 1, i%, x As String, strResult As String
x = "12345789"
For i = 1 To Len(x)
strTemp = Mid(x, i, 1)
Select Case Val(strTemp)
Case 1: strResult = strResult & "一"
Case 2: strResult = strResult & "二"
Case 3: strResult = strResult & "三"
Case 4: strResult = strResult & "四"
Case 5: strResult = strResult & "五"
Case 6: strResult = strResult & "六"
Case 7: strResult = strResult & "七"
Case 8: strResult = strResult & "八"
Case 9: strResult = strResult & "九"
End Select
Next
Debug.Print strResult
End Sub
zou19820704 2005-10-15
  • 打赏
  • 举报
回复
Dim str As String * 1
Dim i As Integer
Dim x As String

x = "123456789"
For i = 1 To Len(x)
str = Mid(x, i, 1)
Select Case Val(str)
Case 1
Text1.Text = Text1.Text & "一"
End Select





自己的方法,希望不是很笨,可是很基础!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧