Malicious Office (OLE) — malware analysis report

Static analysis result for SHA-256 335f9b48a37f611d…

MALICIOUS

Office (OLE)

11.33 MB Created: 2011-08-12 08:13:08 Authoring application: Microsoft Excel First seen: 2012-07-06
MD5: 5e628f08ac49dbda4d77c647b1ca99b9 SHA-1: 71a030652aeda18d16d442c137970e37313c491e SHA-256: 335f9b48a37f611d13187c69ec611a5bfb609d911d563135d5a39a74d6b7d42c
200 Risk Score

Heuristics 4

  • ClamAV: Xls.Dropper.Agent-1559695 critical CLAMAV_DETECTION
    ClamAV detected this file as malware: Xls.Dropper.Agent-1559695
  • Excel 4.0 (XLM) Auto_Open + macro sheet critical OLE_XLM_AUTOOPEN
    Workbook contains an Auto_Open / Auto_Close defined name together with an Excel 4.0 macro sheet — the canonical XLM auto-execution shape used by malware families such as Emotet and QakBot.
  • Legacy XLM macro-virus family marker critical OLE_XLM_LEGACY_MACRO_VIRUS
    Workbook contains an Excel 4.0 macro sheet and legacy macro-virus family or workbook-replication strings. This is a narrow indicator for infected XLM workbooks rather than ordinary formula use.
  • VBA macros detected medium OLE_VBA_MACROS
    Document contains VBA macro code

Extracted artifacts 1

Files carved from inside the sample during analysis.

FilenameKindSourceSize
macros.bas vba-macro oletools.olevba.extract_macros (decoded VBA source) 183978 bytes
SHA-256: 847aef59419809d31e8c117ee700592b10f014c0f6b8084f1a8ce08d2c2120eb
Preview script
First 1,000 lines of the extracted script
Attribute VB_Name = "ThisWorkbook"
Attribute VB_Base = "0{00020819-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet1"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet2"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet3"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet4"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet5"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Module41"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function


Attribute VB_Name = "Sheet7"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet8"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet9"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Sheet10"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True

Attribute VB_Name = "Module1"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function

Attribute VB_Name = "Module11"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function

Attribute VB_Name = "Module12"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function

Attribute VB_Name = "Module13"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function

Attribute VB_Name = "Module14"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function

Attribute VB_Name = "Module2"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
    If mnhom <> "000" Then
      v1 = Left(mnhom, 1)
      v2 = Mid(mnhom, 2, 1)
      v3 = Right(mnhom, 1)
      tbc = RTrim(tbc) & " " & IIf(v1 <> "0", Choose(v1 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mtram, "")

      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
      ElseIf v2 = "0" Then
        If v1 <> "0" And v3 <> "0" Then
          tbc = RTrim(tbc) & " " & mle
        End If
      ElseIf v2 = "1" Then
        tbc = RTrim(tbc) & " " & mmuoif
      End If
      
      If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
        tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
      ElseIf v3 = "5" Then
        If v2 <> "0" Then
          tbc = RTrim(tbc) & " " & mlam
        Else
          tbc = RTrim(tbc) & " " & mnam
        End If
      ElseIf v3 = "1" Then
        If v2 <> "0" And v2 <> "1" Then
          tbc = RTrim(tbc) & " " & mmots
        Else
          tbc = RTrim(tbc) & " " & mmot
        End If
      End If

      tbc = RTrim(tbc) & " " & IIf(mdem = 1, mty, IIf(mdem = 2, mtrieu, IIf(mdem = 3, mngan, "")))
      tbc = LTrim(tbc)
      tbc = UCase(Left(tbc, 1)) & Mid(tbc, 2)
    End If
  Next mdem
  
  mphannguyen = Right(mchuoi, 2)
  If mphannguyen <> "00" Then
    tbc = tbc & DonVi
    v2 = Left(mphannguyen, 1)
    v3 = Right(mphannguyen, 1)
  
    If v2 <> "0" And v2 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v2 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin) & " " & mmuoi
    ElseIf v2 = "0" Then
      If v1 <> "0" And v3 <> "0" Then
        tbc = RTrim(tbc) & " " & mle
      End If
    ElseIf v2 = "1" Then
      tbc = RTrim(tbc) & " " & mmuoif
    End If
      
    If v3 <> "0" And v3 <> "5" And v3 <> "1" Then
      tbc = RTrim(tbc) & " " & Choose(v3 + 1, mkhong, mmot, "hai", "ba", mbon, mnam, msau, mbay, mtam, mchin)
    ElseIf v3 = "5" Then
      If v2 <> "0" Then
        tbc = RTrim(tbc) & " " & mlam
      Else
        tbc = RTrim(tbc) & " " & mnam
      End If
    ElseIf v3 = "1" Then
      If v2 <> "0" And v2 <> "1" Then
        tbc = RTrim(tbc) & " " & mmots
      Else
        tbc = RTrim(tbc) & " " & mmot
      End If
    End If
    
    tien_bang_chu = tbc & " " & TienXu
  Else
    tien_bang_chu = tbc & DonVi
  End If
End Function


Attribute VB_Name = "Module3"
Function tien_bang_chu(Tien As Double, DonVi As String, Optional TienXu As String) As String
  Dim mchuoi As String, mdem As Byte, mnhom As String * 3, tbc As String
  Dim v1 As String * 1, v2 As String * 1, v3 As String * 1
  Dim mphannguyen As String
  
  tien_bang_chu = ""
  If Not IsNumeric(Tien) Then
    MsgBox "Tham so cua ham phai la so", 16
    Exit Function
  End If

  Dim mkhongdong As String, mtram As String, mmuoi As String, mle As String, mmuoif As String
  Dim mlam As String, mnam As String, mmot As String, mmots As String, mty As String, mtrieu As String
  Dim mdong As String, mbon As String, mbay As String
  
  Const mkhong = "không"
  Const mngan = "ngàn"
  Const msau = "sáu"
  Const mtam = "tám"
  Const mchin = "chín"
  
  mkhongdong = mkhong & " " & DonVi
  mtram = "tr" & ChrW(259) & "m"
  mmuoi = "m" & ChrW(432) & ChrW(417) & "i"
  mle = "l" & ChrW(7867)
  mmuoif = "m" & ChrW(432) & ChrW(7901) & "i"
  mlam = "l" & ChrW(259) & "m"
  mnam = "n" & ChrW(259) & "m"
  mmot = "m" & ChrW(7897) & "t"
  mmots = "m" & ChrW(7889) & "t"
  mty = "t" & ChrW(7927)
  mtrieu = "tri" & ChrW(7879) & "u"
  mbon = "b" & ChrW(7889) & "n"
  mbay = "b" & ChrW(7849) & "y"

  If Tien = 0 Then
    tien_bang_chu = mkhongdong
    Exit Function
  End If

  mchuoi = Format$(Tien, "000000000000.00")
  mphannguyen = Left(mchuoi, Len(mchuoi) - 3)
  tbc = ""
  
  For mdem = 1 To 4
    mnhom = Mid$(mphannguyen, mdem * 3 - 2, 3)
…