uronmapu > 01-09-12, 02:15 PM
quanghoasla > 02-09-12, 08:43 PM
Xuân Thanh > 08-09-12, 11:22 AM
Public Function DocSo(Number As Double)
Dim MyArray
Dim Str As String
If Number >= 1E+18 Then DocSo = "#NUM!": Exit Function
Str = Format(Fix(Abs(Number)), "000000000000000000")
MyArray = Array("không ", "m" & ChrW(7897) & "t ", "hai ", "ba ", "b" & ChrW(7889) & "n ", "n" & ChrW(259) & "m ", "sáu ", "b" & ChrW(7843) & "y ", "tám ", "chín ", "tri" & ChrW(7879) & "u, ", "ngàn, ", "t" & ChrW(7927) & ", ", "tri" & ChrW(7879) & "u, ", "ngàn, ", "", "tr" & ChrW(259) & "m ", "m" & ChrW(432) & ChrW(417) & "i ", "không " & "m" & ChrW(432) & ChrW(417) & "i" & " không ", "không " & "m" & ChrW(432) & ChrW(417) & "i", "l" & ChrW(7867), "m" & ChrW(432) & ChrW(417) & "i" & " không", "m" & ChrW(432) & ChrW(417) & "i", "m" & ChrW(432) & ChrW(417) & "i" & " n" & ChrW(259) & "m", "m" & ChrW(432) & ChrW(417) & "i" & " l" & ChrW(259) & "m", "m" & ChrW(7897) & "t " & "m" & ChrW(432) & ChrW(417) & "i", "m" & ChrW(432) & ChrW(7901) & "i", "m" & ChrW(432) & ChrW(417) & "i" & " m" & ChrW(7897) & "t", "m" & ChrW(432) & ChrW(417) & "i" & " m" & ChrW(7889) & "t", "Âm ", ChrW(273) & ChrW(7891) & "ng ", "và ", "xu ")
For i = 1 To Len(Str)
If Left(Str, i) <> 0 And Mid(Str, (Int((i + 2) / 3) - 1) * 3 + 1, 3) <> 0 Then
DocSo = DocSo & MyArray(Mid(Str, i, 1)) & MyArray(-(9 + i / 3) * (i Mod 3 = 0) - (15 + i Mod 3) * (i Mod 3 <> 0))
ElseIf i = 9 And Mid(Str, 7, 3) = 0 And Left(Str, 6) <> 0 Then
DocSo = DocSo & MyArray(12)
End If
Next
DocSo = IIf(Number = 0, MyArray(0) & MyArray(30), "") & IIf(Fix(Number) <> 0, DocSo & MyArray(30), "") & IIf(Fix(Number) <> 0 And Fix(Number) <> Number, MyArray(31), "") & IIf(Fix(Number) <> Number, IIf(Abs(Number - Fix(Number)) < 0.1, "", MyArray(Left(Right(Format(Abs(Number), "#.00"), 2), 1)) & MyArray(17)) & MyArray(Right(Format(Number, "#.00"), 1)) & MyArray(32), "")
DocSo = Replace(Trim(Replace(Replace(Replace(Replace(Replace(Replace(Replace(DocSo, MyArray(18), MyArray(15)), MyArray(19), MyArray(20)), MyArray(21), MyArray(22)), MyArray(23), MyArray(24)), MyArray(25), MyArray(26)), MyArray(27), MyArray(28)), ", " & MyArray(30), " " & MyArray(30))), MyArray(30) & MyArray(31), Split(MyArray(30), " ")(0) & " " & MyArray(31))
If Number < 0 Then DocSo = MyArray(29) & DocSo
DocSo = UCase(Left(DocSo, 1)) & Mid(DocSo, 2) & "."
End Function
uronmapu > 08-09-12, 11:34 PM
changkhoonline77 > 21-09-12, 06:24 PM
camau > 07-10-12, 03:38 PM
Xuân Thanh > 07-12-12, 10:30 AM
wwwphuong > 25-01-13, 11:58 AM