欢迎光临
我们一直在努力

把数字转成英文字_visualbasic教程

建站超值云服务器,限时71元/月

●建立D2T巨集,并把快速键设为Shift Ctrl T。

●写入程式码:

SubD2T()
DimMyStrAsString
MyStr=ActiveCell.Text

IfIsNumeric(MyStr)=TrueThen
ActiveCell.Value=””

SelectCaseLen(MyStr)
Case1
OneDG(MyStr)
Case2
TwoDG(MyStr)
Case3
ThreeDG(MyStr)
Case4
OneDG(Left(MyStr,1))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case5
TwoDG(Left(MyStr,2))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case6
ThreeDG(Left(MyStr,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case7
OneDG(Left(MyStr,1))
ActiveCell.Value=ActiveCell.Value “Millon”
ThreeDG(Mid(MyStr,2,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case8
TwoDG(Left(MyStr,2))
ActiveCell.Value=ActiveCell.Value “Millon”
ThreeDG(Mid(MyStr,3,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case9
ThreeDG(Left(MyStr,3))
ActiveCell.Value=ActiveCell.Value “Millon”
ThreeDG(Mid(MyStr,4,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case10
OneDG(Left(MyStr,1))
ActiveCell.Value=ActiveCell.Value “Billon”
ThreeDG(Mid(MyStr,2,3))
ActiveCell.Value=ActiveCell.Value “Millon”
ThreeDG(Mid(MyStr,5,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
Case11
TwoDG(Left(MyStr,2))
ActiveCell.Value=ActiveCell.Value “Billon”
ThreeDG(Mid(MyStr,3,3))
ActiveCell.Value=ActiveCell.Value “Millon”
ThreeDG(Mid(MyStr,6,3))
ActiveCell.Value=ActiveCell.Value “Thousand”
ThreeDG(Right(MyStr,3))
CaseElse
EndSelect
EndIf
EndSub

SubOneDG(MyStrAsString)
SelectCaseMyStr
Case”0″
IfActiveCell.Value=””ThenActiveCell.Value=ActiveCell.Value “Zero”
Case”1″
ActiveCell.Value=ActiveCell.Value “One”
Case”2″
ActiveCell.Value=ActiveCell.Value “Two”
Case”3″
ActiveCell.Value=ActiveCell.Value “Three”
Case”4″
ActiveCell.Value=ActiveCell.Value “Four”
Case”5″
ActiveCell.Value=ActiveCell.Value “Five”
Case”6″
ActiveCell.Value=ActiveCell.Value “Six”
Case”7″
ActiveCell.Value=ActiveCell.Value “Seven”
Case”8″
ActiveCell.Value=ActiveCell.Value “Eight”
Case”9″
ActiveCell.Value=ActiveCell.Value “Nine”
EndSelect
EndSub

SubTwoDG(MyStrAsString)
SelectCaseMyStr
Case”10″
ActiveCell.Value=ActiveCell.Value “Ten”
Case”11″
ActiveCell.Value=ActiveCell.Value “eleven”
Case”12″
ActiveCell.Value=ActiveCell.Value “Twelve”
Case”13″
ActiveCell.Value=ActiveCell.Value “Thirteen”
Case”14″
ActiveCell.Value=ActiveCell.Value “Fourteen”
Case”15″
ActiveCell.Value=ActiveCell.Value “Fifteen”
Case”16″
ActiveCell.Value=ActiveCell.Value “Sixteen”
Case”17″
ActiveCell.Value=ActiveCell.Value “Seventeen”
Case”18″
ActiveCell.Value=ActiveCell.Value “Eighteen”
Case”19″
ActiveCell.Value=ActiveCell.Value “Nineteen”
CaseElse
SelectCaseLeft(MyStr,1)
Case”2″
ActiveCell.Value=ActiveCell.Value “Twenty”
Case”3″
ActiveCell.Value=ActiveCell.Value “Thirty”
Case”4″
ActiveCell.Value=ActiveCell.Value “Forty”
Case”5″
ActiveCell.Value=ActiveCell.Value “Fifty”
Case”6″
ActiveCell.Value=ActiveCell.Value “Sixty”
Case”7″
ActiveCell.Value=ActiveCell.Value “Seventy”
Case”8″
ActiveCell.Value=ActiveCell.Value “Eighty”
Case”9″
ActiveCell.Value=ActiveCell.Value “Ninety”
EndSelect
OneDG(Right(MyStr,1))
EndSelect

EndSub

SubThreeDG(MyStrAsString)
SelectCaseLeft(MyStr,1)
Case”1″
ActiveCell.Value=ActiveCell.Value “OneHandred”
Case”2″
ActiveCell.Value=ActiveCell.Value “TwoHandred”
Case”3″
ActiveCell.Value=ActiveCell.Value “ThreeHandred”
Case”4″
ActiveCell.Value=ActiveCell.Value “FourHandred”
Case”5″
ActiveCell.Value=ActiveCell.Value “FiveHandred”
Case”6″
ActiveCell.Value=ActiveCell.Value “SixHandred”
Case”7″
ActiveCell.Value=ActiveCell.Value “SevenHandred”
Case”8″
ActiveCell.Value=ActiveCell.Value “EightHandred”
Case”9″
ActiveCell.Value=ActiveCell.Value “NightHandred”
EndSelect
TwoDGRight(MyStr,2)
EndSub
●上面的程式码可以处理到11位数。●随意输入一个未超过11位数的数字,然后把输入游标移到该Cell里。

●一同按下Shift Ctrl T。->

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 把数字转成英文字_visualbasic教程
分享到: 更多 (0)