uronmapu > 07-09-12, 04:32 PM
cannguyen > 07-09-12, 05:06 PM
(07-09-12, 04:32 PM)uronmapu Đã viết: Chào cả nhà
Em bị lỗi này ko biết fix thế nào ạ
Run-time error '13' Type mismatch
Lỗi tại dòng
Đây là đoạn code chuyển số thành chữ
Em xin hỏi thêm làm sao in Phiếu Hóa Đơn thành 2 trang (2 phần)
Liên 1: Giao cho Khách hàng
Liên 2: Công ty giữ
Em chỉ mới làm in được 1 trang thôi
File của em: http://www.mediafire.com/?phg365feb4az7xk
uronmapu > 07-09-12, 06:21 PM
uronmapu > 07-09-12, 07:41 PM
Function VND(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 1E+15 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###############")
SOTIEN = Right(Space(15) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "ngaøn tyû,", "tyû,", "trieäu,", "ngaøn,", "ñoàng ")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 5 Then
Chu = "ñoàng chaün " & Space(1)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 2 And S2 = "0" And S3 <> "0" And S1 >= "0" And I = 5
Dich = "leû" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or _
(S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or _
(S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S2 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or _
(S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
VND = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function AUD(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "ñoâ la UÙc ", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "ñoâ la UÙc" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
AUD = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function CAD(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "ñoâ la Canada", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "ñoâ la Canada" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
CAD = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function EUR(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "Euro", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "Euro" & Space(0)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün. " & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
EUR = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function HKD(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "ñoâ la Hoàng koâng", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "ñoâ la Hoàng coâng" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
HKD = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function GBP(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "baûng Anh ", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "baûng Anh" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
GBP = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function JPY(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "yeân Nhaät", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "yeân Nhaät" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
JPY = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function USD(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "ñoâ la Myõ", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "ñoâ la Myõ" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
USD = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function USA(AMT)
Dim ToRead, Chuoi, NHOM, Word As String
Dim L, J As Byte, W, X, Y, Z As Double
Dim Donvi, HChuc, Khung
If AMT = 0 Then
ToRead = "None"
Else
Donvi = Array("None", "one", "two", "three", "four", "five", "six", _
"seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", _
"fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
HChuc = Array("None", "None", "twenty", "thirty", "forty", "fifty", "sixty", _
"seventy", "eighty", "ninety")
Khung = Array("None", "trillion,", "billion,", "million,", "thousand,", "dollars", "cents")
If AMT < 0 Then
ToRead = "Minus" & Space(1)
Else
ToRead = Space(0)
End If
Chuoi = Format(Abs(AMT), "###############.00") ' 18 Soá haøng ñôn vò vaø 2 soá leû thaäp phaân'
Chuoi = Right(Space(15) & Chuoi, 18)
For L = 1 To 6
NHOM = Mid(Chuoi, L * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If L = 5 And Abs(AMT) > 1 Then
Word = "dollars " & Space(1)
Else
Word = Space(0)
End If
Case ".00"
Word = "only."
Case Else
X = Val(Left(NHOM, 1))
Y = Val(Mid(NHOM, 2, 1))
Z = Val(Right(NHOM, 1))
W = Val(Right(NHOM, 2))
If X = 0 Then
Word = Space(0)
Else
Word = Donvi(X) & Space(1) & "hundred" & Space(1)
If W > 0 And W < 21 Then
Word = Word & "and" & Space(1)
End If
End If
If L = 6 And Abs(AMT) > 1 Then
Word = "and" & Space(1) & Word
End If
If W < 20 And W > 0 Then
Word = Word & Donvi(W) & Space(1)
Else
If W >= 20 Then
Word = Word & HChuc(Y) & Space(1)
If Z > 0 Then
Word = Word & Donvi(Z) & Space(1)
End If
End If
End If
Word = Word & Khung(L) & Space(1)
End Select
ToRead = ToRead & Word
End If
Next L
End If
USA = UCase(Left(ToRead, 1)) & Mid(ToRead, 2)
End Function
Function SJC(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ly"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "chæ", "ly")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "chæ" & Space(0)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün " & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
SJC = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
Function SGD(BaoNhieu)
Dim KetQua, SOTIEN, NHOM, Chu, Dich, S1, S2, S3 As String
Dim I, J, Vitri As Byte, S As Double
Dim Hang, DOC, DEM
If BaoNhieu = 0 Then
KetQua = "Khoâng ñoàng"
Else
If Abs(BaoNhieu) > 999999999999.99 Then
KetQua = "Soá Quùa Lôùn"
Else
If BaoNhieu < 0 Then
KetQua = "Tröø" & Space(1)
Else
KetQua = Space(0)
End If
SOTIEN = Format(Abs(BaoNhieu), "###########0.00")
SOTIEN = Right(Space(12) & SOTIEN, 15)
Hang = Array("None", "traêm", "möôi", "gì ñoù")
DOC = Array("None", "tyû", "trieäu", "ngaøn", "ñoâ la Sinhgapore", "cent.")
DEM = Array("None", "moät", "hai", "ba", "boán", "naêm", "saùu", "baûy", "taùm", "chín")
For I = 1 To 5
NHOM = Mid(SOTIEN, I * 3 - 2, 3)
If NHOM <> Space(3) Then
Select Case NHOM
Case "000"
If I = 4 Then
Chu = "ñoâ la Sinhgapore" & Space(1)
Else
Chu = Space(0)
End If
Case ".00"
If I = 5 Then
Chu = " chaün." & Space(0)
Else
Chu = Space(0)
End If
Case Else
S1 = Left(NHOM, 1)
S2 = Mid(NHOM, 2, 1)
S3 = Right(NHOM, 1)
Chu = Space(0)
Hang(3) = DOC(I)
For J = 1 To 3
Dich = Space(0)
S = Val(Mid(NHOM, J, 1))
If S > 0 Then
Dich = DEM(S) & Space(1) & Hang(J) & Space(1)
End If
Select Case J
Case 2 And S = 1
Dich = "möôøi" & Space(1)
Case 3 And S = 0 And NHOM <> Space(2) & "0"
Dich = Hang(J) & Space(1)
Case 3 And S = 5 And S2 <> Space(1) And S2 <> "0"
Dich = "1" & Mid(Dich, 2) 'Kyù töï en lôø
Case 2 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "linh" & Space(1)
End If
W = Mid(SOTIEN, 14, 2)
If W > "0" And I = 5 Then
Dich = "leû" & Space(1)
End If
Case 1 And S = 0 And S3 <> "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Or (S1 = "0" And I = 5) Then
Dich = "khoâng traêm" & Space(1)
End If
Case 1 And S = 0 And S3 = "0"
If (S1 >= "1" And S1 <= "9") Or (S1 = "0" And I = 1) Or (S1 = "0" And I = 2) Or (S1 = "0" And I = 3) Or (S1 = "0" And I = 4) Then
Dich = "khoâng traêm" & Space(1)
End If
End Select
Chu = Chu & Dich
Next J
End Select
Vitri = InStr(1, Chu, "möôi moät", 1)
If Vitri > 0 Then Mid(Chu, Vitri, 9) = "möôi moát"
KetQua = KetQua & Chu
End If
Next I
End If
End If
SGD = UCase(Left(KetQua, 1)) & Mid(KetQua, 2)
End Function
cannguyen > 08-09-12, 09:55 AM
(07-09-12, 07:41 PM)uronmapu Đã viết: Mình sử dụng đoạn lệnh khác bên dưới ok rồi ah
....
Xuân Thanh > 08-09-12, 09:59 AM
uronmapu > 08-09-12, 10:51 PM
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
bangnguyencong > 24-05-13, 09:33 AM