本帖最后由 CrLf 于 2014-7-16 16:56 编辑
一个示例:- MsgBox [大写数字转阿拉伯数字]("第一千零三十节")
-
- Function [大写数字转阿拉伯数字]([原始字符串])
- Dim [大写数字],[数字列表]
-
- [大写数字] = reReplace([原始字符串],"^[^零一二三四五六七八九十百千两]*","")
- [大写数字] = reReplace([大写数字],"[^零一二三四五六七八九十百千两].*","")
- [原始字符串] = reReplace([原始字符串],"[零一二三四五六七八九十百千两]+","#")
-
- [数字列表]="零一二三四五六七八九"
- For i=0 To Len([数字列表])
- [大写数字]=Replace([大写数字],Mid([数字列表],i+1,1),"+"&i)
- Next
- [大写数字]=Replace([大写数字],"两","+2")
-
- [大写数字] = Replace([大写数字],"十","*10")
- [大写数字] = Replace([大写数字],"百","*100")
- [大写数字] = Replace([大写数字],"千","*1000")
- [大写数字] = Mid([大写数字],2)
- [大写数字转阿拉伯数字] = Replace([原始字符串],"#",Eval([大写数字]))
- End Function
-
- Function reReplace(string1,pattern,string2)
- With New RegExp
- .Pattern=pattern
- reReplace=.Replace(string1,string2)
- End With
- End Function
复制代码
|