Home > Software engineering >  To EXcel in the digital conversion for English want to add some characters how to add in front
To EXcel in the digital conversion for English want to add some characters how to add in front

Time:09-22

 Option Explicit 
Dim StrNO (19) As String
Dim Unit (8) As String
Dim StrTENs (9) As String
Public Function NumberToString (Number As a Double) As String
Dim Str As String, BeforePoint As String, AfterPoint As String, tmpStr As String
Dim Point As Integer
Dim nBit As Integer
Dim CurString As String
Dim nNumLen As Integer
Dim T As String
Call the Init
Str=CStr (Round (Number, 2))
'Str=Number
If InStr (1, Str, ". ")=0 Then
BeforePoint=Str
AfterPoint=""
The Else
BeforePoint=Left (Str, InStr (1, Str, ". ") - 1)
T=Right (Str, Len (Str) - InStr (1, Str, ""))
If Len (T) & lt; 2 Then AfterPoint=Val (T) * 10
If Len (T)=2 Then AfterPoint=Val (T)
If Len (T) & gt; 2 Then AfterPoint=Val (Left (T, 2))
End the If
If Len (BeforePoint) & gt; 12 Then
NumberToString="Big."
The Exit Function
End the If
Str=""
The Do While Len (BeforePoint) & gt; 0
NNumLen=Len (BeforePoint)
If nNumLen Mod and 3=0 Then
CurString=Left (BeforePoint, 3)
BeforePoint=Right (BeforePoint, nNumLen - 3)
The Else
CurString=Left (BeforePoint, (3) nNumLen Mod)
BeforePoint=Right (BeforePoint nNumLen - (nNumLen Mod 3))
End the If
NBit=Len (BeforePoint)/3
TmpStr=DecodeHundred (CurString)
If (BeforePoint=String (Len (BeforePoint), "0") Or nBit=0) And Len (CurString)=3 Then
If CInt (Left (CurString, 1)) & lt;> 0 And CInt (CurString, 2) (Right) & lt;> 0 Then
'tmpStr=Left (tmpStr, InStr (1, tmpStr, Unit (4)) + Len (Unit (4))) & amp; The Unit (8) & amp; "" & amp; Right (tmpStr, Len (tmpStr) - (InStr (1, tmpStr, Unit (4)) + Len (Unit (4))))
The Else 'If CInt (Left (CurString, 1)) & lt;> 0 And CInt (CurString, 2) (Right)=0 Then
'tmpStr=Unit (8) & amp; "" & amp; TmpStr
End the If
End the If
If nBit=0 Then
Str=Trim (Str & amp; "" & amp; TmpStr)
The Else
Str=Trim (Str & amp; "" & amp; TmpStr & amp; "" & amp; The Unit (nBit))
End the If
If Left (Str, 3)=Unit (8) Then Str=Trim (Right (Str, Len (Str) - 3))
If BeforePoint=String (Len (BeforePoint), "0") Then Exit the Do
'the Debug. Print Str
Loop
BeforePoint=Str
If Len (AfterPoint) & gt; 0 Then
AfterPoint=Unit (6) & amp; "" & amp; DecodeHundred (AfterPoint) & amp; "" & amp; The Unit (5)
The Else
AfterPoint=Unit (5)
End the If
NumberToString=BeforePoint & amp; "" & amp; AfterPoint
End the Function
Private Function DecodeHundred (HundredString As String) As String
Dim TMP As Integer
If Len (HundredString) & gt; 0 And Len (HundredString) & lt;=3 Then
The Select Case Len (HundredString)
Case 1
TMP=CInt (HundredString)
If TMP & lt;> 0 Then DecodeHundred=StrNO (TMP)
Case 2
TMP=CInt (HundredString)
If TMP & lt;> 0 Then
If (TMP & lt; 20) Then
DecodeHundred=StrNO (TMP)
The Else
If CInt (Right (HundredString, 1))=0 Then
DecodeHundred=StrTENs (Int (TMP/10))
The Else
DecodeHundred=StrTENs (Int (TMP/10)) & amp; "-" & amp; StrNO (CInt (HundredString, 1)) (Right)
End the If
End the If
End the If
Case 3
If CInt (Left (HundredString, 1)) & lt;> 0 Then
DecodeHundred=StrNO (CInt (Left (HundredString, 1))) & amp; "" & amp; The Unit (4) & amp; "" & amp; DecodeHundred (HundredString, 2) (Right)
The Else
DecodeHundred=DecodeHundred (HundredString, 2) (Right)
End the If
In Case the Else
End the Select
End the If
End the Function
Private Sub Init ()
If StrNO (1) & lt;> "ONE" Then
StrNO (1)="ONE"
StrNO (2)="TWO"
StrNO (3)="THREE"
StrNO (4)="FOUR"
StrNO (5)="FIVE"
StrNO (6)="SIX"
StrNO (7)="SEVEN"
StrNO (8)="EIGHT"
StrNO (9)="NINE"
StrNO (10)="TEN"
StrNO (11)="ELEVEN"
StrNO (12)="TWEVEL"
StrNO (13)="THIRTEEN"
StrNO (14)="FOURTEEN"
StrNO (15)="FIFTEEN"
StrNO (16)="SIXTEEN"
StrNO (17)="SEVENTEEN"
StrNO="EIGHTEEN (18)
StrNO (19)="NINETEEN"
StrTENs (1)="TEN"
StrTENs (2)="TWENTY"
StrTENs (3)="THIRTY"
StrTENs (4)="FORTY"
StrTENs (5)="looking"
StrTENs (6)="SIXTY"
StrTENs (7)="SEVENTY"
StrTENs (8)="EIGHTy"
StrTENs (9)="NINETY"
The Unit (1)="THOUSAND"
Unit (2)="m letters"
Unit (3)="pull in"
The Unit (4)="HUNDRED"
The Unit (5)="ONLY"
The Unit (6)="CENTS"
The Unit (7)="Cents"
The Unit (8)="And"
End the If
End Sub

Want to join in the front of the English results SAY US DOLLARS, 10 yuan bounty

CodePudding user response:

O great god assists

CodePudding user response:

 MsgBox "SAY US DOLLARS, BOUNTY" & amp; NumberToString (1000000) 

CodePudding user response:

10 yuan bounty?



You simply don't mention this is better!!!!!!
  • Related