把数字转成英文字

页面导航:首页 > 软件编程 > vb.net > 把数字转成英文字

把数字转成英文字

来源: 作者: 时间:2016-02-05 12:32 【

●建立D2T巨集,并把快速键设为Shift + Ctrl + T。●写入程式码: Sub D2T()Dim MyStr As StringMyStr = ActiveCell.TextIf IsNumeric(MyS

 

 

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

 

●写入程式码:

 

Sub D2T()

Dim MyStr As String

MyStr = ActiveCell.Text

 

If IsNumeric(MyStr) = True Then

ActiveCell.Value = ""

 

Select Case Len(MyStr)

Case 1

OneDG (MyStr)

Case 2

TwoDG (MyStr)

Case 3

ThreeDG (MyStr)

Case 4

OneDG (Left(MyStr, 1))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 5

TwoDG (Left(MyStr, 2))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 6

ThreeDG (Left(MyStr, 3))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 7

OneDG (Left(MyStr, 1))

ActiveCell.Value = ActiveCell.Value + " Millon "

ThreeDG (Mid(MyStr, 2, 3))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 8

TwoDG (Left(MyStr, 2))

ActiveCell.Value = ActiveCell.Value + " Millon "

ThreeDG (Mid(MyStr, 3, 3))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 9

ThreeDG (Left(MyStr, 3))

ActiveCell.Value = ActiveCell.Value + " Millon "

ThreeDG (Mid(MyStr, 4, 3))

ActiveCell.Value = ActiveCell.Value + " Thousand "

ThreeDG (Right(MyStr, 3))

Case 10

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))

Case 11

TwoDG (Left(MyStr, 2))

ActiveCell.Value = ActiveCell.Value + " Billon "

ThreeDG (Mid(MyStr, 3, 3))<

Tags:

相关文章

    文章评论

    
    <