VBA 數字轉英文 | excel vba數字轉英文
b2007إ߳oӥAAyk~ OONODaHаݸӦpץH¡CFunctionSpellNumber(ByValMyNumber) DimDollars,Cents,Temp DimDecimalPlace,Count ReDimPlace(9)AsString Place(2)="Thousand" Place(3)="Million" Place(4)="Billion" Place(5)="Trillion" Stringrepresentationofamount. MyNumber=Trim(Str(MyNumber)) Positionofdecimalplace0ifnone. DecimalPlace=InStr(MyNumber,".") ConvertcentsandsetMyNumbertodollaramount. IfDecimalPlace>0Then Cents=GetTens(Left(Mid(MyNumber,DecimalPlace+1)&_ "00...
b2007إ߳oӥAAyk~ OONODaHаݸӦpץH¡C
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
String representation of amount.
MyNumber = Trim(Str(MyNumber))
Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars