标题:请问能不能让这个代码简单点???
取消只看楼主
大话西游
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-4-5
 问题点数:0 回复次数:1 
请问能不能让这个代码简单点???
这是对从 初一 到 三十 的汉字转换为数子,可太长了,能不能有简单点的方法?


Public Function ZhanHuan(NuberN As String) As Integer
Dim TempInter As Long
If NuberN = "初一" Then
TempInter = "1"
ElseIf NuberN = "初二" Then
TempInter = "2"
ElseIf NuberN = "初三" Then
TempInter = "3"
ElseIf NuberN = "初四" Then
TempInter = "4"
ElseIf NuberN = "初五" Then
TempInter = "5"
ElseIf NuberN = "初六" Then
TempInter = "6"
ElseIf NuberN = "初七" Then
TempInter = "7"
ElseIf NuberN = "初八" Then
TempInter = "8"
ElseIf NuberN = "初九" Then
TempInter = "9"
ElseIf NuberN = "初十" Then
TempInter = "10"
ElseIf NuberN = "十一" Then
TempInter = "11"
ElseIf NuberN = "十二" Then
TempInter = "12"
ElseIf NuberN = "十三" Then
TempInter = "13"
ElseIf NuberN = "十四" Then
TempInter = "14"
ElseIf NuberN = "十五" Then
TempInter = "15"
ElseIf NuberN = "十六" Then
TempInter = "16"
ElseIf NuberN = "十七" Then
TempInter = "17"
ElseIf NuberN = "十八" Then
TempInter = "18"
ElseIf NuberN = "十九" Then
TempInter = "19"
ElseIf NuberN = "二十" Then
TempInter = "20"
ElseIf NuberN = "廿一" Then
TempInter = "21"
ElseIf NuberN = "廿三" Then
TempInter = "23"
ElseIf NuberN = "廿四" Then
TempInter = "24"
ElseIf NuberN = "廿五" Then
TempInter = "25"
ElseIf NuberN = "廿六" Then
TempInter = "26"
ElseIf NuberN = "廿七" Then
TempInter = "27"
ElseIf NuberN = "廿八" Then
TempInter = "28"
ElseIf NuberN = "廿九" Then
TempInter = "29"
ElseIf NuberN = "三十" Then
TempInter = "30"
ElseIf NuberN = "卅一" Then
TempInter = "31"
ElseIf NuberN = "廿二" Then
TempInter = "22"
Else
If IsNumeric(NuberN) Then
TempInter = NuberN
Else
'MsgBox "输入错误,请输入日期类型" & vbCrLf & "如:1 、2、初一、初十、廿一、卅一等", vbExclamation, "错误"
Exit Function
End If
End If
ZhanHuan = TempInter
End Function
搜索更多相关主题的帖子: 代码 
2006-04-05 22:19
大话西游
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2006-4-5
得分:0 
要是数字转换为汉字好说哈,可是汉字到数子。
能说详细点吗?

2006-04-06 16:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-55406-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.430632 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved