|
时光鸟 发表于 2013-6-16 12:16
这个使用面是比较窄,我也是在网上找了好久没找到好用的,才想着要自己写一个用
有没有简单版的,就是纯中文数字转成阿拉伯数字 0~999
网上找到一个阿拉伯数字转中文小写的:(想反过来转,纯中文小写转阿拉伯数字)
Function ToChin(Num As String) As String
Const Snum As String = "零一二三四五六七八九十"
Dim L As Integer, I As Integer, S As String, N As Integer
L = Len(Num)
If L > 3 Then
MsgBox "数字 " & Num & " 超出三位数范围。", vbOKOnly, "错误提示"
Exit Function
End If
N = L
For I = 1 To L
S = Mid(Num, I, 1)
If N = 3 Then
ToChin = ToChin & Mid(Snum, Val(S) + 1, 1) & "百"
ElseIf N = 2 Then
If S <> "0" Then
If S = "1" And L = 2 Then
ToChin = ToChin & "十"
Else
ToChin = ToChin & Mid(Snum, Val(S) + 1, 1) & "十"
End If
Else
If Mid(Num, I + 1, 1) <> "0" Then
ToChin = ToChin & Mid(Snum, Val(S) + 1, 1)
End If
End If
Else
If S <> "0" Or S = "0" And L = 1 Then
ToChin = ToChin & Mid(Snum, Val(Mid(Num, I, 1)) + 1, 1)
End If
End If
N = N - 1
Next I
End Function
|
|