Tôi có chép trên GPE addins đọc số tiếng anh, không biết chép có thiếu chữ nào không mà đọc
1020: JPY One thousand two hundred and only.
hay
120000: JPY One hundred and thousand only.
thì không đúng, mất 20.
Nhờ các bạn sửa hộ. Cám ơn!
Gốc của UDF này là USD, tôi có sửa thành JPY.
1020: JPY One thousand two hundred and only.
hay
120000: JPY One hundred and thousand only.
thì không đúng, mất 20.
Nhờ các bạn sửa hộ. Cám ơn!
Gốc của UDF này là USD, tôi có sửa thành JPY.
PHP:
Public Function JPE(MoneyAmount)
If MoneyAmount = 0 Then
toread = "None"
Else
UnitCount = Array("None", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", _
"elevent", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
TenCount = Array("None", "None", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
GroupCount = Array("None", "billion", "million", "thousand", "", "cents")
If MoneyAmount < 0 Then
toread = "Minus" & Space(1)
Else
toread = Space(0)
End If
mystring = Format(Abs(MoneyAmount), "###############.00")
mystring = Right(Space(12) & mystring, 15)
For NN = 1 To 5
mygroup = Mid(mystring, NN * 3 - 2, 3)
If mygroup <> Space(3) Then
Select Case mygroup
Case "000"
If NN = 4 And Abs(MoneyAmount) > 1 Then
MyWord = "" & Space(1)
Else
MyWord = Space(0)
End If
Case ".00", ",00"
MyWord = "only."
Case Else
XX = Val(Left(mygroup, 1))
YY = Val(Mid(mygroup, 2, 1))
ZZ = Val(Right(mygroup, 1))
WW = Val(Right(mygroup, 2))
If XX = 0 Then
MyWord = Space(0)
Else
MyWord = UnitCount(XX) & Space(1) & "hundred" & Space(1)
If WW > 0 And WW < 21 Then
MyWord = MyWord & "and" & Space(1)
End If
End If
If NN = 5 And Abs(MoneyAmount) > 1 Then
MyWord = "and" & Space(1) & MyWord
End If
If WW < 20 And WW > 0 Then
MyWord = MyWord & UnitCount(WW) & Space(1)
Else
If WW > 20 Then
MyWord = MyWord & TenCount(YY) & Space(1)
If ZZ > 0 Then
MyWord = MyWord & UnitCount(ZZ) & Space(1)
End If
End If
End If
MyWord = MyWord & GroupCount(NN) & Space(1)
End Select
toread = toread & MyWord
End If
Next NN
End If
JPE = "JPY " & UCase(Left(toread, 1)) & Mid(toread, 2)
'JPE = "Japanese Yen " & UCase(Left(toread, 1)) & Mid(toread, 2)
End Function