Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

財務_收支單一覽表.vb 129KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. Option Strict Off
  2. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  3. Imports Microsoft.Office.Interop.Excel.Constants
  4. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  5. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  6. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  7. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  8. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  9. Imports Microsoft.Office.Interop.Excel.XlWindowState
  10. Imports Microsoft.Office.Interop.Excel
  11. Imports System.IO
  12. Imports System.Data.SqlClient
  13. Public Class 財務_收支單一覽表
  14. ReadOnly ds, ds1, ds2, ds3, ds4, ds5, ds6 As New DataSet
  15. Dim DTP, 單據日期, 原日期字串 As String : Dim N1 As Integer : Dim N2 As Integer
  16. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  17. Dim boo, boo1 As Boolean
  18. Private Sub Set_清單()
  19. 日期彙總_dgv.DataSource = Nothing : ds3.Clear()
  20. 日期彙總_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  21. 日期彙總_dgv.ColumnHeadersHeight = 25 : 日期彙總_dgv.AllowUserToAddRows = False : 日期彙總_dgv.RowTemplate.Height = 25
  22. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  23. SQL_營運成本收支單一覽表_查詢清單純日期() : da.Fill(ds3) : 日期彙總_dgv.DataSource = ds3.Tables(0) : conn.Close()
  24. 日期彙總_dgv.Columns(0).FillWeight = 100 : 日期彙總_dgv.Columns(0).ReadOnly = True
  25. End Sub
  26. Private Sub Set_清單1()
  27. 單據彙總_dgv.DataSource = Nothing : ds1.Clear()
  28. 單據彙總_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  29. 單據彙總_dgv.ColumnHeadersHeight = 25
  30. 單據彙總_dgv.AllowUserToAddRows = False
  31. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  32. SQL_營運成本收支單一覽表_查詢清單() : da.Fill(ds1) : 單據彙總_dgv.DataSource = ds1.Tables(0) : conn.Close()
  33. 單據彙總_dgv.RowTemplate.Height = 25
  34. 單據彙總_dgv.Columns(0).FillWeight = 160 : 單據彙總_dgv.Columns(1).Visible = False : 單據彙總_dgv.Columns(2).FillWeight = 100 : 單據彙總_dgv.Columns(3).Visible = False
  35. 單據彙總_dgv.Columns(4).FillWeight = 100 : 單據彙總_dgv.Columns(5).Visible = False : 單據彙總_dgv.Columns(6).Visible = False
  36. End Sub
  37. Private Sub Set_清單2()
  38. 財務彙總_dgv.DataSource = Nothing : ds2.Clear()
  39. 財務彙總_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  40. 財務彙總_dgv.ColumnHeadersHeight = 25
  41. 財務彙總_dgv.AllowUserToAddRows = False
  42. 財務彙總_dgv.RowTemplate.Height = 30
  43. If 全部_ch.Checked = True And 含稅_ch.Checked = False And 非稅_ch.Checked = False Then
  44. SQL2 = ""
  45. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = True And 非稅_ch.Checked = False Then
  46. SQL2 = " AND (公帳流水帳.含稅 = 1)"
  47. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = False And 非稅_ch.Checked = True Then
  48. SQL2 = " AND (公帳流水帳.含稅 = 0 OR 公帳流水帳.含稅 IS NULL)"
  49. End If
  50. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公帳控制表.公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  51. SQL_營運成本收支單一覽表_查詢清單2() : da.Fill(ds2) : 財務彙總_dgv.DataSource = ds2.Tables(0) : conn.Close()
  52. 財務彙總_dgv.Columns(0).Visible = False : 財務彙總_dgv.Columns(1).FillWeight = 140 : 財務彙總_dgv.Columns(2).FillWeight = 140 : 財務彙總_dgv.Columns(3).FillWeight = 140
  53. 財務彙總_dgv.Columns(4).FillWeight = 100 : 財務彙總_dgv.Columns(5).FillWeight = 100 : 財務彙總_dgv.Columns(6).FillWeight = 100 : 財務彙總_dgv.Columns(7).FillWeight = 100
  54. 財務彙總_dgv.Columns(8).FillWeight = 100 : 財務彙總_dgv.Columns(9).FillWeight = 100
  55. 財務彙總_dgv.Columns(4).Visible = False : 財務彙總_dgv.Columns(5).Visible = False
  56. If 彙總匯率_ch.Checked = False Then
  57. 財務彙總_dgv.Columns(8).Visible = False : 財務彙總_dgv.Columns(9).Visible = False
  58. Else
  59. 財務彙總_dgv.Columns(8).Visible = False : 財務彙總_dgv.Columns(9).Visible = False
  60. End If
  61. 財務彙總_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 財務彙總_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 財務彙總_dgv.Columns(4).DefaultCellStyle.Format = "#,##0"
  62. 財務彙總_dgv.Columns(5).DefaultCellStyle.Format = "#,##0"
  63. 財務彙總_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  64. 財務彙總_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  65. 財務彙總_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  66. 財務彙總_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  67. 財務彙總_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  68. 財務彙總_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  69. 財務彙總_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  70. 財務彙總_dgv.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  71. 財務彙總_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  72. 財務彙總_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  73. 財務彙總_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  74. 財務彙總_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  75. For i As Integer = 0 To 財務彙總_dgv.Columns.Count - 1 : 財務彙總_dgv.Columns(i).ReadOnly = True : Next
  76. End Sub
  77. Private Sub Set_清單3()
  78. 財務彙總_天_dgv.DataSource = Nothing : ds4.Clear()
  79. 財務彙總_天_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  80. 財務彙總_天_dgv.ColumnHeadersHeight = 25
  81. 財務彙總_天_dgv.AllowUserToAddRows = False
  82. 財務彙總_天_dgv.RowTemplate.Height = 30
  83. If 全部_ch.Checked = True And 含稅_ch.Checked = False And 非稅_ch.Checked = False Then
  84. SQL2 = ""
  85. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = True And 非稅_ch.Checked = False Then
  86. SQL2 = " AND (公帳流水帳.含稅 = 1)"
  87. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = False And 非稅_ch.Checked = True Then
  88. SQL2 = " AND (公帳流水帳.含稅 = 0 OR 公帳流水帳.含稅 IS NULL)"
  89. End If
  90. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公帳控制表.公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  91. SQL_營運成本收支單一覽表_查詢清單3() : da.Fill(ds4) : 財務彙總_天_dgv.DataSource = ds4.Tables(0) : conn.Close()
  92. 財務彙總_天_dgv.Columns(0).Visible = False : 財務彙總_天_dgv.Columns(1).FillWeight = 140 : 財務彙總_天_dgv.Columns(2).FillWeight = 140 : 財務彙總_天_dgv.Columns(3).FillWeight = 140
  93. 財務彙總_天_dgv.Columns(4).FillWeight = 100 : 財務彙總_天_dgv.Columns(5).FillWeight = 100 : 財務彙總_天_dgv.Columns(6).FillWeight = 100 : 財務彙總_天_dgv.Columns(7).FillWeight = 100
  94. 財務彙總_天_dgv.Columns(8).FillWeight = 100 : 財務彙總_天_dgv.Columns(9).FillWeight = 100
  95. 財務彙總_天_dgv.Columns(4).Visible = False : 財務彙總_天_dgv.Columns(5).Visible = False
  96. If 彙總匯率_ch.Checked = False Then
  97. 財務彙總_天_dgv.Columns(8).Visible = False : 財務彙總_天_dgv.Columns(9).Visible = False
  98. Else
  99. 財務彙總_天_dgv.Columns(8).Visible = False : 財務彙總_天_dgv.Columns(9).Visible = False
  100. End If
  101. 財務彙總_天_dgv.Columns(6).DefaultCellStyle.Format = "#,##0" : 財務彙總_天_dgv.Columns(7).DefaultCellStyle.Format = "#,##0" : 財務彙總_天_dgv.Columns(4).DefaultCellStyle.Format = "#,##0"
  102. 財務彙總_天_dgv.Columns(5).DefaultCellStyle.Format = "#,##0"
  103. 財務彙總_天_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  104. 財務彙總_天_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  105. 財務彙總_天_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  106. 財務彙總_天_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  107. 財務彙總_天_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  108. 財務彙總_天_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  109. 財務彙總_天_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  110. 財務彙總_天_dgv.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  111. 財務彙總_天_dgv.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  112. 財務彙總_天_dgv.Columns(8).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  113. 財務彙總_天_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
  114. 財務彙總_天_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  115. For i As Integer = 0 To 財務彙總_天_dgv.Columns.Count - 1 : 財務彙總_天_dgv.Columns(i).ReadOnly = True : Next
  116. End Sub
  117. ' 宣告全局變量
  118. Dim dt As New System.Data.DataTable()
  119. Private Sub 初始化DataGridView()
  120. 明細_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  121. 明細_dgv.ColumnHeadersHeight = 40 : 明細_dgv.AllowUserToAddRows = False : 明細_dgv.RowTemplate.Height = 35
  122. dt.Clear() : 加載數據到DataTable()
  123. 明細_dgv.DataSource = dt
  124. End Sub
  125. Private Sub 加載數據到DataTable()
  126. If 全部_ch.Checked = True And 含稅_ch.Checked = False And 非稅_ch.Checked = False Then : SQL2 = ""
  127. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = True And 非稅_ch.Checked = False Then : SQL2 = " AND (公帳流水帳.含稅 = 1)"
  128. ElseIf 全部_ch.Checked = False And 含稅_ch.Checked = False And 非稅_ch.Checked = True Then : SQL2 = " AND (公帳流水帳.含稅 = 0 OR 公帳流水帳.含稅 IS NULL)" : End If
  129. If 公司編號_cb.Text = "全部" Or 公司編號_cb.Text = "" Then : PA51 = "" : Else : PA51 = " AND (公帳控制表.公司編號 LIKE N'" & 公司編號_cb.Text & "')" : End If
  130. If boo = True Then : PA55 = 申請日期_dtp.Text : Else : PA55 = "" : End If
  131. dt.Clear()
  132. Using conn As New SqlConnection(ConString) : conn.Open()
  133. Using cmd As New SqlCommand() : cmd.Connection = conn
  134. If boo1 = True Then : cmd.CommandText = SQL_營運成本收支單一覽表_查詢費用清單()
  135. Else : cmd.CommandText = SQL_營運成本收支單一覽表_查詢清單4() : End If
  136. Using adapter As New SqlDataAdapter(cmd)
  137. adapter.Fill(dt)
  138. End Using
  139. End Using
  140. End Using
  141. End Sub
  142. Public Sub 添加昨日結餘行()
  143. 原日期字串 = 單據日期
  144. Dim 日期 As DateTime = DateTime.ParseExact(原日期字串, "yyyy/MM/dd", Globalization.CultureInfo.InvariantCulture)
  145. Dim 減一天 As DateTime = 日期.AddDays(-1) : Dim 減一天字串 As String = 減一天.ToString("yyyy/MM/dd")
  146. 單據日期 = 減一天字串 : Dim 結餘 As Integer
  147. For I As Integer = 0 To 正壘算_dgv.Rows.Count - 1
  148. If 單據日期 = 正壘算_dgv.Rows(I).Cells("日期").Value.ToString Then
  149. 結餘 = 正壘算_dgv.Rows(I).Cells("每日結餘").Value.ToString : Exit For
  150. End If
  151. Next
  152. Dim newRow As DataRow = dt.NewRow()
  153. newRow("項次") = 0 : newRow("支付單號") = "OE-" & Strings.Left(原日期字串, 4) & Strings.Mid(原日期字串, 6, 2) & Strings.Right(原日期字串, 2) & "-999"
  154. newRow("會計科目") = "昨日結餘" : newRow("用途") = "" : newRow("零用金") = 0
  155. newRow("支票") = 0 : newRow("收入") = 結餘 : newRow("支出") = 0 : newRow("票期") = "" : newRow("匯率") = 1
  156. newRow("幣別") = "NTD" : newRow("類別") = "" : newRow("流水號") = ""
  157. dt.Rows.InsertAt(newRow, 0) : 明細_dgv.Refresh()
  158. End Sub
  159. Public Sub 添加今日結餘行()
  160. Dim newRow As DataRow = dt.NewRow()
  161. Dim 零用金合計 As Decimal = 0 : Dim 收入合計 As Decimal = 0 : Dim 支出合計 As Decimal = 0 : Dim 結算 As Decimal = 0
  162. For Each row As DataRow In dt.Rows ' 計算所有行的合計
  163. If Not Convert.IsDBNull(row("零用金")) Then : 零用金合計 += Convert.ToDecimal(row("零用金")) : End If
  164. If Not Convert.IsDBNull(row("收入")) Then : 收入合計 += Convert.ToDecimal(row("收入")) : End If
  165. If Not Convert.IsDBNull(row("支出")) Then : 支出合計 -= Convert.ToDecimal(row("支出")) : End If
  166. Next
  167. 結算 = 零用金合計 + 收入合計 + 支出合計
  168. newRow("項次") = dt.Rows.Count + 1 : newRow("支付單號") = "**自動計算**" : newRow("會計科目") = "今日結餘" : newRow("用途") = "" : newRow("零用金") = 零用金合計 : newRow("支票") = 0
  169. If 結算 >= 0 Then : newRow("收入") = 結算 : newRow("支出") = 0 : Else : newRow("收入") = 0 : newRow("支出") = 結算 * -1 : End If
  170. newRow("票期") = "" : newRow("匯率") = 1 : newRow("幣別") = "NTD" : newRow("類別") = "" : newRow("流水號") = ""
  171. dt.Rows.Add(newRow) : 明細_dgv.Refresh()
  172. End Sub
  173. Public Sub 更新數據源()
  174. 加載數據到DataTable() : 明細_dgv.Refresh()
  175. End Sub
  176. Private Sub Set_費用清單()
  177. 初始化DataGridView()
  178. 明細_dgv.Columns(0).FillWeight = 50 : 明細_dgv.Columns(1).FillWeight = 250 : 明細_dgv.Columns(2).FillWeight = 250 : 明細_dgv.Columns(3).FillWeight = 380
  179. 明細_dgv.Columns(6).FillWeight = 140 : 明細_dgv.Columns(7).FillWeight = 140
  180. 明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(10).Visible = False : 明細_dgv.Columns(11).Visible = False
  181. 明細_dgv.Columns(12).Visible = False : 明細_dgv.Columns(4).Visible = False : 明細_dgv.Columns(5).Visible = False : 明細_dgv.Columns(8).Visible = False
  182. If 彙總匯率_ch.Checked = False Then
  183. 明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(10).Visible = False
  184. Else
  185. 明細_dgv.Columns(9).Visible = False : 明細_dgv.Columns(10).Visible = False
  186. End If
  187. For i As Integer = 0 To 明細_dgv.Columns.Count - 1 : 明細_dgv.Columns(i).ReadOnly = True : Next
  188. 明細_dgv.Columns(4).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(5).DefaultCellStyle.Format = "#,##0" : 明細_dgv.Columns(6).DefaultCellStyle.Format = "#,##0"
  189. 明細_dgv.Columns(7).DefaultCellStyle.Format = "#,##0"
  190. 明細_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  191. 明細_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  192. 明細_dgv.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  193. 明細_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : 明細_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  194. 明細_dgv.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(9).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  195. 明細_dgv.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(10).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  196. 明細_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter : 明細_dgv.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
  197. 添加昨日結餘行() : 添加今日結餘行()
  198. 台幣現金_tb.Text = "0" : 台幣支出_tb.Text = "0" : 台幣現金餘額_tb.Text = "0" : 台幣零用金_tb.Text = "0" : 台幣支票_tb.Text = "0"
  199. 人民幣零用金_tb.Text = "0" : 人民幣支票_tb.Text = "0" : 人民幣現金_tb.Text = "0" : 人民幣支出_tb.Text = "0" : 人民幣現金餘額_tb.Text = "0"
  200. For i As Integer = 0 To 明細_dgv.Rows.Count - 1
  201. 明細_dgv.Rows(i).Cells("項次").Value = i + 1
  202. If 明細_dgv.Rows(i).Cells("幣別").Value = "台幣現金" Then
  203. 台幣現金_tb.Text = Val(台幣現金_tb.Text) + 明細_dgv.Rows(i).Cells("收入").Value
  204. 台幣支出_tb.Text = Val(台幣支出_tb.Text) + 明細_dgv.Rows(i).Cells("支出").Value
  205. 台幣零用金_tb.Text = Val(台幣零用金_tb.Text) + 明細_dgv.Rows(i).Cells("零用金").Value
  206. 台幣支票_tb.Text = Val(台幣支票_tb.Text) + 明細_dgv.Rows(i).Cells("支票").Value
  207. End If
  208. If 明細_dgv.Rows(i).Cells("幣別").Value = "人民幣現金" Then
  209. 人民幣現金_tb.Text = Val(人民幣現金_tb.Text) + 明細_dgv.Rows(i).Cells("收入").Value
  210. 人民幣支出_tb.Text = Val(人民幣支出_tb.Text) + 明細_dgv.Rows(i).Cells("支出").Value
  211. 人民幣零用金_tb.Text = Val(人民幣零用金_tb.Text) + 明細_dgv.Rows(i).Cells("零用金").Value
  212. 人民幣支票_tb.Text = Val(人民幣支票_tb.Text) + 明細_dgv.Rows(i).Cells("支票").Value
  213. End If
  214. Next i
  215. 台幣現金餘額_tb.Text = Val(台幣零用金_tb.Text) + Val(台幣現金_tb.Text) - Val(台幣支出_tb.Text)
  216. 人民幣現金餘額_tb.Text = Val(人民幣零用金_tb.Text) + Val(人民幣現金_tb.Text) - Val(人民幣支出_tb.Text)
  217. 台幣現金_tb.Text = Strings.Format(Val(台幣現金_tb.Text), "#,##0") : 台幣支出_tb.Text = Strings.Format(Val(台幣支出_tb.Text), "#,##0")
  218. 台幣現金餘額_tb.Text = Strings.Format(Val(台幣現金餘額_tb.Text), "#,##0")
  219. 台幣零用金_tb.Text = Strings.Format(Val(台幣零用金_tb.Text), "#,##0") : 台幣支票_tb.Text = Strings.Format(Val(台幣支票_tb.Text), "#,##0")
  220. 人民幣零用金_tb.Text = Strings.Format(Val(人民幣零用金_tb.Text), "#,##0") : 人民幣支票_tb.Text = Strings.Format(Val(人民幣支票_tb.Text), "#,##0")
  221. 人民幣現金_tb.Text = Strings.Format(Val(人民幣現金_tb.Text), "#,##0")
  222. 人民幣支出_tb.Text = Strings.Format(Val(人民幣支出_tb.Text), "#,##0") : 人民幣現金餘額_tb.Text = Strings.Format(Val(人民幣現金餘額_tb.Text), "#,##0")
  223. End Sub
  224. Private Sub Set_日結()
  225. 壘算_dgv.DataSource = Nothing : ds6.Clear()
  226. 壘算_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  227. 壘算_dgv.ColumnHeadersHeight = 25 : 壘算_dgv.AllowUserToAddRows = False : 壘算_dgv.RowTemplate.Height = 25
  228. SQL_日帳結算() : da.Fill(ds6) : 壘算_dgv.DataSource = ds6.Tables(0) : conn.Close()
  229. 正壘算_dgv.Rows.Clear() : 正壘算_dgv.AllowUserToAddRows = False
  230. Dim 今天 As Date = Date.Today
  231. Dim 當前日期 As Date = 壘算_dgv.Rows(0).Cells("日期").Value.ToString
  232. Do While 當前日期 <= 今天
  233. 正壘算_dgv.Rows.Add(當前日期.ToString("yyyy/MM/dd"), 0D, 0D)
  234. 當前日期 = 當前日期.AddDays(1)
  235. Loop
  236. For i As Integer = 0 To 正壘算_dgv.Rows.Count - 1
  237. For J As Integer = 0 To 壘算_dgv.Rows.Count - 1
  238. If 正壘算_dgv.Rows(i).Cells("日期").Value.ToString = 壘算_dgv.Rows(J).Cells("日期").Value.ToString Then
  239. 正壘算_dgv.Rows(i).Cells("日結").Value = 壘算_dgv.Rows(J).Cells("日結").Value : Exit For
  240. End If
  241. Next
  242. If i = 0 Then
  243. 正壘算_dgv.Rows(i).Cells("每日結餘").Value = 正壘算_dgv.Rows(i).Cells("日結").Value
  244. Else
  245. 正壘算_dgv.Rows(i).Cells("每日結餘").Value = 正壘算_dgv.Rows(i).Cells("日結").Value + 正壘算_dgv.Rows(i - 1).Cells("每日結餘").Value
  246. End If
  247. Next
  248. End Sub
  249. Private Sub 日期格式()
  250. If 會計月_ch.Checked = True Then
  251. '-------------日期一----------------------------------------------------------------------------------------
  252. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 開始日期_dtp.Value = DTP
  253. 開始日期_dtp.Value = 結束日期_dtp.Value.AddMonths(-1)
  254. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "26" : 開始日期_dtp.Value = DTP
  255. '-------------日期二----------------------------------------------------------------------------------------
  256. DTP = Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 8) & "25" : 結束日期_dtp.Value = DTP
  257. Else
  258. 開始日期_dtp.Value = 結束日期_dtp.Value
  259. '-------------日期一----------------------------------------------------------------------------------------
  260. DTP = Strings.Left(Strings.Format(開始日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 開始日期_dtp.Value = DTP
  261. '-------------日期二----------------------------------------------------------------------------------------
  262. DTP = Strings.Left(Strings.Format(結束日期_dtp.Value, "yyyy/MM/dd"), 8) & "01" : 結束日期_dtp.Value = DTP
  263. 結束日期_dtp.Value = 結束日期_dtp.Value.AddMonths(1) : 結束日期_dtp.Value = 結束日期_dtp.Value.AddDays(-1)
  264. End If
  265. End Sub
  266. Private Sub 載入公司編號cb()
  267. SQL_公司編號_下拉清單() : 公司編號_cb.Items.Clear() : 公司編號_cb.Items.Add("全部")
  268. While (dr.Read()) : 公司編號_cb.Items.Add(dr("公司編號")) : End While : conn.Close()
  269. End Sub
  270. Private Sub 營運成本收支單一覽表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  271. Me.MdiParent = ICS_ASMS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  272. 正壘算_dgv.Columns.Clear()
  273. 正壘算_dgv.Columns.Add("日期", "日期")
  274. 正壘算_dgv.Columns.Add("日結", "日結")
  275. 正壘算_dgv.Columns.Add("每日結餘", "每日結餘")
  276. End Sub
  277. Private Sub 營運成本收支單一覽表_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  278. Set_日結() : System.Windows.Forms.Application.DoEvents()
  279. 載入公司編號cb() : System.Windows.Forms.Application.DoEvents()
  280. DTP = Strings.Left(Strings.Format(Today(), "yyyy/MM/dd"), 8) & "01"
  281. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = Today() : 支付單列印成EXCEL.Enabled = False
  282. 日期格式() : 明細_rb.Checked = True : 財務彙總_天_dgv.Visible = False
  283. If 公司 = True Then : Else : 公司編號_lb.Visible = False : 公司編號_cb.Visible = False : End If
  284. SQL_讀取公司名稱() : If dr.Read() Then : 公司名稱.Text = dr("公司名稱") : End If : conn.Close()
  285. End Sub
  286. Dim 已超出 As Boolean
  287. Private Sub 財務彙總_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 財務彙總_dgv.MouseUp
  288. 'If 財務彙總_dgv.SelectedCells.Count = 1 Then : MsgBox(財務彙總_dgv.SelectedCells(0).ColumnIndex & " " & 財務彙總_dgv.SelectedCells(0).RowIndex) : End If
  289. If 財務彙總_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If
  290. If 財務彙總_dgv.SelectedCells.Count > 0 Then
  291. If 財務彙總_dgv.SelectedCells(0).ColumnIndex >= 4 And 財務彙總_dgv.SelectedCells(0).ColumnIndex <= 7 Then
  292. If 已超出 = False Then
  293. Dim x As Double = 0
  294. For i As Integer = 0 To 財務彙總_dgv.SelectedCells.Count - 1
  295. x += Val(財務彙總_dgv.Rows(財務彙總_dgv.SelectedCells.Item(i).RowIndex).Cells(財務彙總_dgv.SelectedCells.Item(i).ColumnIndex).Value)
  296. Next i : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0")
  297. Else : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0") : End If
  298. Else : 已超出 = True : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0")
  299. End If
  300. End If
  301. End Sub
  302. Private Sub 明細_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 明細_dgv.MouseUp
  303. 'If 明細_dgv.SelectedCells.Count = 1 Then : MsgBox(明細_dgv.SelectedCells(0).ColumnIndex & " " & 明細_dgv.SelectedCells(0).RowIndex) : End If
  304. If 明細_dgv.SelectedCells.Count = 1 Then : 已超出 = False : End If
  305. If 明細_dgv.SelectedCells.Count > 0 Then
  306. If 明細_dgv.SelectedCells(0).ColumnIndex >= 4 And 明細_dgv.SelectedCells(0).ColumnIndex <= 7 Then
  307. If 已超出 = False Then
  308. Dim x As Double = 0
  309. For i As Integer = 0 To 明細_dgv.SelectedCells.Count - 1
  310. x += Val(明細_dgv.Rows(明細_dgv.SelectedCells.Item(i).RowIndex).Cells(明細_dgv.SelectedCells.Item(i).ColumnIndex).Value)
  311. Next i : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0")
  312. Else : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0") : End If
  313. Else : 已超出 = True : ICS_ASMS_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0")
  314. End If
  315. End If
  316. End Sub
  317. Private Sub 財務彙總_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 財務彙總_dgv.CellClick
  318. If e.RowIndex = -1 Then : Else
  319. PA56 = 財務彙總_dgv(3, e.RowIndex).Value.ToString
  320. boo1 = False
  321. 支付單列印成EXCEL.Enabled = True
  322. Set_費用清單()
  323. End If
  324. End Sub
  325. Private Sub 單據彙總_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 單據彙總_dgv.CellClick
  326. If e.RowIndex = -1 Then : Else
  327. 收支單號_tb.Text = 單據彙總_dgv(0, e.RowIndex).Value.ToString : 驗證碼_tb.Text = 單據彙總_dgv(6, e.RowIndex).Value.ToString
  328. 申請人_tb.Text = 單據彙總_dgv(1, e.RowIndex).Value.ToString : 申請日期_dtp.Value = 單據彙總_dgv(2, e.RowIndex).Value.ToString
  329. 審核人_tb.Text = 單據彙總_dgv(3, e.RowIndex).Value.ToString : 圖片編碼_tb.Text = 單據彙總_dgv(5, e.RowIndex).Value.ToString
  330. If 單據彙總_dgv(4, e.RowIndex).Value.ToString = "" Then
  331. 審核日期_dtp.Value = 單據彙總_dgv(2, e.RowIndex).Value.ToString
  332. Else
  333. 審核日期_dtp.Value = 單據彙總_dgv(4, e.RowIndex).Value.ToString
  334. End If
  335. Set_費用清單()
  336. End If
  337. End Sub
  338. Private Sub 日期彙總_dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles 日期彙總_dgv.CellClick
  339. If e.RowIndex = -1 Then : Else
  340. boo1 = True
  341. boo = True : 支付單列印成EXCEL.Enabled = True
  342. If 日期浮動_cb.Checked = True Then
  343. 結束日期_dtp.Value = 日期彙總_dgv(0, e.RowIndex).Value.ToString
  344. End If
  345. 申請日期_dtp.Value = 日期彙總_dgv(0, e.RowIndex).Value.ToString : 單據日期 = 日期彙總_dgv(0, e.RowIndex).Value.ToString
  346. Set_費用清單() : Set_清單3() : Set_清單2()
  347. If 單據彙總_dgv.Rows.Count > 0 Then
  348. 圖片編碼_tb.Text = 單據彙總_dgv(5, 0).Value.ToString
  349. End If
  350. 憑證張數_tb.Text = ""
  351. End If
  352. End Sub
  353. Private Sub 單據彙總_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 單據彙總_dgv.RowPostPaint
  354. Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) : Dim linePen2 As New Pen(Color.Green, 2)
  355. If e.RowIndex = 單據彙總_dgv.Rows.Count - 1 Then
  356. Exit Sub
  357. Else
  358. If 單據彙總_dgv(2, e.RowIndex).Value.ToString <> 單據彙總_dgv(2, e.RowIndex + 1).Value.ToString Then
  359. Dim startX As Integer = IIf(單據彙總_dgv.RowHeadersVisible, 單據彙總_dgv.RowHeadersWidth, 0)
  360. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  361. Dim endX As Integer = startX + 單據彙總_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 單據彙總_dgv.HorizontalScrollingOffset
  362. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  363. Exit Sub
  364. End If
  365. End If
  366. End Sub
  367. Private Sub 財務彙總_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 財務彙總_dgv.RowPostPaint
  368. Dim linePen As New Pen(Color.Blue, 2) : Dim linePen1 As New Pen(Color.Red, 2) : Dim linePen2 As New Pen(Color.Green, 2)
  369. If e.RowIndex = 財務彙總_dgv.Rows.Count - 1 Then
  370. Exit Sub
  371. Else
  372. If 財務彙總_dgv(0, e.RowIndex).Value.ToString <> 財務彙總_dgv(0, e.RowIndex + 1).Value.ToString Then
  373. Dim startX As Integer = IIf(財務彙總_dgv.RowHeadersVisible, 財務彙總_dgv.RowHeadersWidth, 0)
  374. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  375. Dim endX As Integer = startX + 財務彙總_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 財務彙總_dgv.HorizontalScrollingOffset
  376. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  377. Exit Sub
  378. End If
  379. If 財務彙總_dgv(8, e.RowIndex).Value.ToString <> 財務彙總_dgv(8, e.RowIndex + 1).Value.ToString Then
  380. Dim startX As Integer = IIf(財務彙總_dgv.RowHeadersVisible, 財務彙總_dgv.RowHeadersWidth, 0)
  381. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  382. Dim endX As Integer = startX + 財務彙總_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 財務彙總_dgv.HorizontalScrollingOffset
  383. e.Graphics.DrawLine(linePen2, startX, startY, endX, startY)
  384. Exit Sub
  385. End If
  386. If 財務彙總_dgv(1, e.RowIndex).Value.ToString <> 財務彙總_dgv(1, e.RowIndex + 1).Value.ToString Then
  387. Dim startX As Integer = IIf(財務彙總_dgv.RowHeadersVisible, 財務彙總_dgv.RowHeadersWidth, 0)
  388. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  389. Dim endX As Integer = startX + 財務彙總_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 財務彙總_dgv.HorizontalScrollingOffset
  390. e.Graphics.DrawLine(linePen1, startX, startY, endX, startY)
  391. Exit Sub
  392. End If
  393. End If
  394. End Sub
  395. Private Sub 日期浮動_cb_CheckedChanged(sender As Object, e As EventArgs) Handles 日期浮動_cb.Click
  396. If 日期浮動_cb.Checked = False Then
  397. 日期浮動_cb.Checked = False : 當月_bt.PerformClick()
  398. End If
  399. End Sub
  400. Private Sub 全部_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 全部_ch.Click
  401. 全部_ch.Checked = True : 含稅_ch.Checked = False : 非稅_ch.Checked = False : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  402. End Sub
  403. Private Sub 含稅_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 含稅_ch.Click
  404. 全部_ch.Checked = False : 含稅_ch.Checked = True : 非稅_ch.Checked = False : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  405. End Sub
  406. Private Sub 非稅_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 非稅_ch.Click
  407. 全部_ch.Checked = False : 含稅_ch.Checked = False : 非稅_ch.Checked = True : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  408. End Sub
  409. Private Sub 當日_bt_Click(sender As Object, e As EventArgs) Handles 當日_bt.Click
  410. 中間日期_dtp.Value = Today
  411. 日期浮動_cb.Checked = False : DTP = Strings.Format(Today(), "yyyy/MM/dd")
  412. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = DTP
  413. boo = False
  414. Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  415. End Sub
  416. Private Sub 當月_bt_Click(sender As Object, e As EventArgs) Handles 當月_bt.Click
  417. 中間日期_dtp.Value = Today
  418. 日期浮動_cb.Checked = False : DTP = Strings.Left(Strings.Format(Today(), "yyyy/MM/dd"), 8) & "01"
  419. 開始日期_dtp.Value = DTP : 結束日期_dtp.Value = Today()
  420. boo = False
  421. Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  422. End Sub
  423. Private Sub 彙總計算()
  424. If 明細_rb.Checked = False And 彙總_rb.Checked = True Then
  425. 支付單列印成EXCEL.Enabled = False
  426. 台幣現金_tb.Text = "0" : 台幣支出_tb.Text = "0" : 台幣現金餘額_tb.Text = "0" : 台幣零用金_tb.Text = "0" : 台幣支票_tb.Text = "0"
  427. 人民幣零用金_tb.Text = "0" : 人民幣支票_tb.Text = "0" : 人民幣現金_tb.Text = "0" : 人民幣支出_tb.Text = "0" : 人民幣現金餘額_tb.Text = "0"
  428. For i As Integer = 0 To 財務彙總_dgv.Rows.Count - 1
  429. If 財務彙總_dgv.Rows(i).Cells("幣別").Value = "台幣現金" Then
  430. 台幣現金_tb.Text = Val(台幣現金_tb.Text) + 財務彙總_dgv.Rows(i).Cells("收入").Value
  431. 台幣支出_tb.Text = Val(台幣支出_tb.Text) + 財務彙總_dgv.Rows(i).Cells("支出").Value
  432. 台幣零用金_tb.Text = Val(台幣零用金_tb.Text) + 財務彙總_dgv.Rows(i).Cells("零用金").Value
  433. 台幣支票_tb.Text = Val(台幣支票_tb.Text) + 財務彙總_dgv.Rows(i).Cells("支票").Value
  434. End If
  435. If 財務彙總_dgv.Rows(i).Cells("幣別").Value = "人民幣現金" Then
  436. If 財務彙總_dgv.Rows(i).Cells("主項").Value <> "上月結存" Then
  437. 人民幣現金_tb.Text = Val(人民幣現金_tb.Text) + 財務彙總_dgv.Rows(i).Cells("收入").Value
  438. 人民幣支出_tb.Text = Val(人民幣支出_tb.Text) + 財務彙總_dgv.Rows(i).Cells("支出").Value
  439. 人民幣零用金_tb.Text = Val(人民幣零用金_tb.Text) + 財務彙總_dgv.Rows(i).Cells("零用金").Value
  440. 人民幣支票_tb.Text = Val(人民幣支票_tb.Text) + 財務彙總_dgv.Rows(i).Cells("支票").Value
  441. End If
  442. End If
  443. Next i
  444. 台幣現金餘額_tb.Text = Val(台幣零用金_tb.Text) + Val(台幣現金_tb.Text) - Val(台幣支出_tb.Text)
  445. 人民幣現金餘額_tb.Text = Val(人民幣零用金_tb.Text) + Val(人民幣現金_tb.Text) - Val(人民幣支出_tb.Text)
  446. 台幣現金_tb.Text = Strings.Format(Val(台幣現金_tb.Text), "#,##0") : 台幣支出_tb.Text = Strings.Format(Val(台幣支出_tb.Text), "#,##0")
  447. 台幣現金餘額_tb.Text = Strings.Format(Val(台幣現金餘額_tb.Text), "#,##0")
  448. 台幣零用金_tb.Text = Strings.Format(Val(台幣零用金_tb.Text), "#,##0") : 台幣支票_tb.Text = Strings.Format(Val(台幣支票_tb.Text), "#,##0")
  449. 人民幣零用金_tb.Text = Strings.Format(Val(人民幣零用金_tb.Text), "#,##0") : 人民幣支票_tb.Text = Strings.Format(Val(人民幣支票_tb.Text), "#,##0")
  450. 人民幣現金_tb.Text = Strings.Format(Val(人民幣現金_tb.Text), "#,##0")
  451. 人民幣支出_tb.Text = Strings.Format(Val(人民幣支出_tb.Text), "#,##0") : 人民幣現金餘額_tb.Text = Strings.Format(Val(人民幣現金餘額_tb.Text), "#,##0")
  452. End If
  453. End Sub
  454. Private Sub 上個月_bt_Click(sender As Object, e As EventArgs) Handles 上個月_bt.Click
  455. 日期浮動_cb.Checked = False
  456. If 會計月_ch.Checked = True Then
  457. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  458. 開始日期_dtp.Value = 中間日期_dtp.Value
  459. 結束日期_dtp.Value = 中間日期_dtp.Value
  460. Else
  461. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(-1)
  462. 開始日期_dtp.Value = 中間日期_dtp.Value
  463. 結束日期_dtp.Value = 中間日期_dtp.Value
  464. End If
  465. boo = False
  466. 日期格式() : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  467. End Sub
  468. Private Sub 下個月_bt_Click(sender As Object, e As EventArgs) Handles 下個月_bt.Click
  469. 日期浮動_cb.Checked = False
  470. If 會計月_ch.Checked = True Then
  471. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
  472. 開始日期_dtp.Value = 中間日期_dtp.Value
  473. 結束日期_dtp.Value = 中間日期_dtp.Value
  474. Else
  475. 中間日期_dtp.Value = 中間日期_dtp.Value.AddMonths(1)
  476. 開始日期_dtp.Value = 中間日期_dtp.Value
  477. 結束日期_dtp.Value = 中間日期_dtp.Value
  478. End If : boo = False : 日期格式() : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  479. End Sub
  480. Private Sub 開始日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 開始日期_dtp.ValueChanged
  481. If 日期浮動_cb.Checked = True Then
  482. Set_清單1() : Set_清單2() : 彙總計算()
  483. Else
  484. Set_清單1() : Set_清單() : Set_清單2() : 彙總計算()
  485. End If
  486. End Sub
  487. Private Sub 結束日期_dtp_ValueChanged(sender As Object, e As EventArgs) Handles 結束日期_dtp.ValueChanged
  488. If 日期浮動_cb.Checked = True Then
  489. Set_清單1() : Set_清單2() : 彙總計算()
  490. Else
  491. Set_清單1() : Set_清單() : Set_清單2() : 彙總計算()
  492. End If
  493. End Sub
  494. Private Sub 會計月_CheckedChanged(sender As Object, e As EventArgs) Handles 會計月_ch.Click
  495. 會計月_ch.Checked = True : 一般月_ch.Checked = False : 日期格式() : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  496. End Sub
  497. Private Sub 一般月_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 一般月_ch.Click
  498. 會計月_ch.Checked = False : 一般月_ch.Checked = True : 日期格式() : Set_費用清單() : Set_清單() : Set_清單2() : 彙總計算()
  499. End Sub
  500. Private Sub 明細_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 明細_rb.Click
  501. 明細_dgv.Visible = True : 財務彙總_天_dgv.Visible = False
  502. 明細_rb.Checked = True : 彙總_rb.Checked = False
  503. 台幣現金_tb.Text = "0" : 台幣支出_tb.Text = "0" : 台幣現金餘額_tb.Text = "0" : 台幣零用金_tb.Text = "0" : 台幣支票_tb.Text = "0" ': 單據彙總_dgv.Enabled = True
  504. End Sub
  505. Private Sub 彙總_rb_CheckedChanged(sender As Object, e As EventArgs) Handles 彙總_rb.Click
  506. 明細_dgv.Visible = False : 財務彙總_天_dgv.Visible = True
  507. 明細_rb.Checked = False : 彙總_rb.Checked = True
  508. 收支單號_tb.Text = "" : 申請人_tb.Text = "" : 審核人_tb.Text = "" : 明細_dgv.DataSource = Nothing : ds.Clear() ': 單據彙總_dgv.Enabled = False
  509. 彙總計算()
  510. End Sub
  511. Private Sub 圖片編碼_tb_TextChanged(sender As Object, e As EventArgs) Handles 圖片編碼_tb.TextChanged
  512. SQL_營運成本收支單一覽表_查詢簽名檔圖片()
  513. While dr.Read() = True
  514. Dim unused As Byte() = New Byte(-1) {}
  515. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  516. Dim oStream As New MemoryStream(bytes)
  517. 簽名圖_pb.Image = Bitmap.FromStream(oStream)
  518. End While
  519. conn.Close()
  520. 簽名圖_pb.SizeMode = 4
  521. End Sub
  522. Private Sub 彙總匯率_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 彙總匯率_ch.Click
  523. Set_清單() : Set_清單2()
  524. End Sub
  525. Private Sub 支付單列印成EXCEL_Click(sender As Object, e As EventArgs) Handles 支付單列印成EXCEL.Click
  526. If 明細_rb.Checked = False And 彙總_rb.Checked = True Then
  527. MsgBox("請點選明細才能列印")
  528. ElseIf 明細_rb.Checked = True And 彙總_rb.Checked = False Then
  529. 列印.ShowDialog() : 列印.BringToFront()
  530. xlApp = CType(CreateObject("Excel.Application"), Application)
  531. xlBook = xlApp.Workbooks.Add : xlApp.DisplayAlerts = True : xlBook.Activate() : xlSheet = NewMethod(xlBook)
  532. xlSheet.Activate() : xlApp.Visible = True : xlApp.Application.WindowState = xlMaximized
  533. If BL1 Then
  534. Dim dat As String = 明細_dgv.Rows(0).Cells("支付單號").Value.ToString
  535. Dim startIndex As Integer = dat.IndexOf("-") + 1
  536. Dim datePart As String
  537. Dim dateValue As DateTime
  538. Dim dat1 As String
  539. If boo1 = True Then
  540. datePart = dat.Substring(startIndex, 8)
  541. If DateTime.TryParseExact(datePart, "yyyyMMdd", Nothing, System.Globalization.DateTimeStyles.None, dateValue) Then
  542. Dim formattedDate As String = dateValue.ToString("yyyy/MM/dd")
  543. dat1 = formattedDate
  544. Else
  545. dat1 = "無效日期"
  546. End If
  547. Else
  548. datePart = DateTime.Now.ToString("yyyyMM")
  549. dat1 = DateTime.Now.ToString("yyyy/MM")
  550. End If
  551. Dim firstCellValue As Object = 明細_dgv.Rows(0).Cells("會計科目").Value
  552. Dim allSame As Boolean = True
  553. For i As Integer = 1 To 明細_dgv.Rows.Count - 1
  554. If Not Object.Equals(明細_dgv.Rows(i).Cells("會計科目").Value, firstCellValue) Then
  555. allSame = False
  556. Exit For
  557. End If
  558. Next
  559. If allSame Then
  560. xlSheet.Cells(2, 3) = 明細_dgv.Rows(0).Cells("會計科目").Value & "-用途說明"
  561. Else
  562. xlSheet.Cells(2, 3) = "用途說明"
  563. End If
  564. xlSheet.Cells(1, 1) = 公司名稱.Text & "收支粘貼憑證用紙-" & dat1
  565. xlSheet.Cells(2, 1) = "憑證編號" : xlSheet.Cells(2, 2) = "編號" : xlSheet.Cells(2, 9) = "金額"
  566. xlSheet.Cells(2, 10) = "附件" : xlSheet.Cells(3, 10) = "憑證" : xlSheet.Cells(2, 8) = "收" & vbLf & "支"
  567. xlSheet.Cells(4, 10) = 憑證張數_tb.Text & vbCrLf & "張"
  568. If 顯示單據_cb.Checked = True Then
  569. xlSheet.Cells(2, 7) = "單據" & vbLf & "編號"
  570. End If
  571. For i As Integer = 0 To 明細_dgv.Rows.Count - 2
  572. If i <> 0 Then
  573. xlSheet.Cells(i + 4, 2) = i
  574. End If
  575. If allSame Then
  576. xlSheet.Cells(i + 4, 3) = 明細_dgv.Rows(i).Cells("用途").Value
  577. If 顯示單據_cb.Checked = True Then
  578. xlSheet.Cells(i + 4, 7) = "'" + 明細_dgv.Rows(i).Cells("票期").Value
  579. End If
  580. Else
  581. xlSheet.Cells(i + 4, 3) = 明細_dgv.Rows(i).Cells("會計科目").Value
  582. xlSheet.Cells(i + 4, 4) = 明細_dgv.Rows(i).Cells("用途").Value
  583. If 顯示單據_cb.Checked = True Then
  584. xlSheet.Cells(i + 4, 7) = "'" + 明細_dgv.Rows(i).Cells("票期").Value
  585. End If
  586. End If
  587. xlSheet.Cells(i + 4, 11) = 明細_dgv.Rows(i).Cells("用途").Value
  588. If 明細_dgv.Rows(i).Cells("收入").Value = 0 And 明細_dgv.Rows(i).Cells("支出").Value <> 0 Then
  589. If i <> 0 Then
  590. xlSheet.Cells(i + 4, 8) = "支"
  591. End If
  592. Dim value1 As Double = Convert.ToDouble(明細_dgv.Rows(i).Cells("支出").Value)
  593. Dim formattedValue1 As String = value1.ToString("#,##0")
  594. xlSheet.Cells(i + 4, 9) = formattedValue1
  595. 'Dim str As String = 大寫轉換(明細_dgv.Rows(i).Cells("支出").Value)
  596. 'xlSheet.Cells(i + 4, 9) = str & " 元整"
  597. ElseIf 明細_dgv.Rows(i).Cells("收入").Value <> 0 And 明細_dgv.Rows(i).Cells("支出").Value = 0 Then
  598. If i <> 0 Then
  599. xlSheet.Cells(i + 4, 8) = "收"
  600. End If
  601. Dim value2 As Double = Convert.ToDouble(明細_dgv.Rows(i).Cells("收入").Value)
  602. Dim formattedValue2 As String = value2.ToString("#,##0")
  603. xlSheet.Cells(i + 4, 9) = formattedValue2
  604. 'Dim str As String = 大寫轉換(明細_dgv.Rows(i).Cells("收入").Value)
  605. 'xlSheet.Cells(i + 4, 9) = str & " 元整"
  606. End If
  607. N2 = i + 4
  608. Next i
  609. Dim 台幣現金餘額 As Double
  610. Dim index As Integer = 明細_dgv.Rows.Count - 1
  611. xlSheet.Cells(N2 + 1, 2) = "今日結餘 : "
  612. If 明細_dgv.Rows(index).Cells("收入").Value = 0 And 明細_dgv.Rows(index).Cells("支出").Value <> 0 Then
  613. 台幣現金餘額 = Convert.ToDouble(明細_dgv.Rows(index).Cells("支出").Value) * -1
  614. ElseIf 明細_dgv.Rows(index).Cells("收入").Value <> 0 And 明細_dgv.Rows(index).Cells("支出").Value = 0 Then
  615. 台幣現金餘額 = Convert.ToDouble(明細_dgv.Rows(index).Cells("收入").Value)
  616. Else
  617. 台幣現金餘額 = 0
  618. End If
  619. xlSheet.Cells(N2 + 1, 9) = 台幣現金餘額.ToString("#,##0")
  620. SQL_公司稱謂()
  621. If dr.Read() Then
  622. xlSheet.Cells(N2 + 2, 7) = If(Not IsDBNull(dr("編號一")), dr("編號一").ToString(), "")
  623. xlSheet.Cells(N2 + 2, 6) = If(Not IsDBNull(dr("編號二")), dr("編號二").ToString(), "")
  624. xlSheet.Cells(N2 + 2, 5) = If(Not IsDBNull(dr("編號三")), dr("編號三").ToString(), "")
  625. xlSheet.Cells(N2 + 2, 4) = If(Not IsDBNull(dr("編號四")), dr("編號四").ToString(), "")
  626. xlSheet.Cells(N2 + 2, 3) = If(Not IsDBNull(dr("編號五")), dr("編號五").ToString(), "")
  627. xlSheet.Cells(N2 + 2, 1) = If(Not IsDBNull(dr("編號六")), dr("編號六").ToString(), "")
  628. xlSheet.Cells(N2 + 2, 9) = If(Not IsDBNull(dr("編號七")), dr("編號七").ToString(), "")
  629. End If
  630. AA(xlApp, xlSheet, allSame)
  631. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  632. '----轉成PDF-----
  633. Dim pdfFolderPath As String = Path.Combine(System.Windows.Forms.Application.StartupPath, "pdf")
  634. If Not Directory.Exists(pdfFolderPath) Then
  635. Directory.CreateDirectory(pdfFolderPath)
  636. End If
  637. Dim pdfFilePath As String = Path.Combine(pdfFolderPath, datePart & "-傳票.pdf")
  638. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdfFilePath, XlFixedFormatQuality.xlQualityStandard, True)
  639. '--------
  640. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized : xlBook.Close(False)
  641. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  642. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  643. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  644. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  645. Try
  646. Dim chromePath As String = "C:\Program Files\Google\Chrome\Application\chrome.exe"
  647. If System.IO.File.Exists(chromePath) Then
  648. Dim process As New Process()
  649. process.StartInfo.FileName = "chrome"
  650. process.StartInfo.Arguments = """" & pdfFilePath & """"
  651. process.Start()
  652. Else : Dim edgePath As String = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
  653. If System.IO.File.Exists(edgePath) Then
  654. Dim process As New Process()
  655. process.StartInfo.FileName = "msedge"
  656. process.StartInfo.Arguments = """" & pdfFilePath & """"
  657. process.Start()
  658. Else
  659. Process.Start(pdfFilePath)
  660. End If
  661. End If
  662. Catch ex As Exception
  663. MsgBox("以存檔至桌面 。" & vbCrLf & "檔案名稱:" & datePart & "-傳票.pdf")
  664. End Try
  665. Else
  666. xlSheet.Cells(1, 1) = 公司名稱.Text & "收支一覽表-" & 開始日期_dtp.Value.ToString("yyyy/MM/dd") & "~" & 結束日期_dtp.Value.ToString("yyyy/MM/dd")
  667. xlSheet.Cells(2, 1) = "主項" : xlSheet.Cells(2, 2) = "子項" : xlSheet.Cells(2, 3) = "子細項"
  668. xlSheet.Cells(2, 4) = "收入" : xlSheet.Cells(2, 5) = "支出"
  669. Dim 支出合計 As Double = 0 : Dim 收入合計 As Double = 0
  670. For i As Integer = 0 To 財務彙總_dgv.Rows.Count - 1
  671. Dim 支出 As Double = Convert.ToDouble(財務彙總_dgv.Rows(i).Cells("支出").Value)
  672. Dim 收入 As Double = Convert.ToDouble(財務彙總_dgv.Rows(i).Cells("收入").Value)
  673. 支出合計 += 支出
  674. 收入合計 += 收入
  675. xlSheet.Cells(i + 3, 1) = 財務彙總_dgv.Rows(i).Cells("主項").Value
  676. xlSheet.Cells(i + 3, 2) = 財務彙總_dgv.Rows(i).Cells("子項").Value
  677. xlSheet.Cells(i + 3, 3) = 財務彙總_dgv.Rows(i).Cells("子細項").Value
  678. xlSheet.Cells(i + 3, 4) = 收入.ToString("#,##0")
  679. xlSheet.Cells(i + 3, 5) = 支出.ToString("#,##0")
  680. N2 = i + 4
  681. Next i
  682. xlSheet.Cells(N2, 3) = "合計" : xlSheet.Cells(N2, 4) = 收入合計.ToString("#,##0") : xlSheet.Cells(N2, 5) = 支出合計.ToString("#,##0")
  683. xlSheet.Cells(N2 + 1, 3) = "總計" : xlSheet.Cells(N2 + 1, 4) = (收入合計 - 支出合計).ToString("#,##0")
  684. BB(xlApp, xlSheet)
  685. xlApp.Sheets(2).Delete : xlSheet.PageSetup.PrintArea = ""
  686. '----轉成PDF-----
  687. Dim pdfFolderPath As String = Path.Combine(System.Windows.Forms.Application.StartupPath, "pdf")
  688. If Not Directory.Exists(pdfFolderPath) Then
  689. Directory.CreateDirectory(pdfFolderPath)
  690. End If
  691. Dim pdfFilePath As String = Path.Combine(pdfFolderPath, "收支一覽表.pdf")
  692. xlBook.Sheets(1).ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdfFilePath, XlFixedFormatQuality.xlQualityStandard, True)
  693. '--------
  694. xlApp.Cells.Select() : xlApp.Application.WindowState = xlMinimized : xlBook.Close(False)
  695. Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
  696. Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
  697. Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
  698. xlApp.Quit() : xlSheet = Nothing : xlBook = Nothing : xlApp = Nothing : GC.Collect()
  699. Try
  700. Dim chromePath As String = "C:\Program Files\Google\Chrome\Application\chrome.exe"
  701. If System.IO.File.Exists(chromePath) Then
  702. Dim process As New Process()
  703. process.StartInfo.FileName = "chrome"
  704. process.StartInfo.Arguments = """" & pdfFilePath & """"
  705. process.Start()
  706. Else : Dim edgePath As String = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
  707. If System.IO.File.Exists(edgePath) Then
  708. Dim process As New Process()
  709. process.StartInfo.FileName = "msedge"
  710. process.StartInfo.Arguments = """" & pdfFilePath & """"
  711. process.Start()
  712. Else
  713. Process.Start(pdfFilePath)
  714. End If
  715. End If
  716. Catch ex As Exception
  717. MsgBox("以存檔至桌面 。" & vbCrLf & "檔案名稱:收支一覽表.pdf")
  718. End Try
  719. End If
  720. End If
  721. End Sub
  722. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  723. Return CType(xlBook.Worksheets.Add, Worksheet)
  724. End Function
  725. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  726. xlSheet.Activate() : xlSheet.Parent.Windows(1).View = XlWindowView.xlPageLayoutView : xlSheet.Cells.Select()
  727. With myExcel.Selection.Font : .Name = "標楷體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  728. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  729. End With
  730. xlSheet.Range("A2:E" & N2 + 1).Select()
  731. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  732. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  733. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  734. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  735. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  736. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  737. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  738. myExcel.Application.PrintCommunication = False
  739. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  740. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  741. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  742. .LeftMargin = myExcel.Application.InchesToPoints(0.25) : .RightMargin = myExcel.Application.InchesToPoints(0.25) : .TopMargin = myExcel.Application.InchesToPoints(0.75)
  743. .BottomMargin = myExcel.Application.InchesToPoints(0.75) : .HeaderMargin = myExcel.Application.InchesToPoints(0.3) : .FooterMargin = myExcel.Application.InchesToPoints(0.3)
  744. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = True : .CenterVertically = False : .Draft = False : .FirstPageNumber = xlAutomatic
  745. .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = 0 : .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False
  746. .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  747. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = ""
  748. .EvenPage.CenterFooter.Text = "" : .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = ""
  749. .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = "" : .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  750. End With : myExcel.Application.PrintCommunication = True
  751. xlSheet.Columns("A:A").ColumnWidth = 15 : xlSheet.Columns("B:B").ColumnWidth = 15 : xlSheet.Columns("C:C").ColumnWidth = 21
  752. xlSheet.Columns("D:D").ColumnWidth = 15 : xlSheet.Columns("E:E").ColumnWidth = 15
  753. xlSheet.Range("A1:E1").Select()
  754. With myExcel.Selection.Font : .Name = "標楷體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  755. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  756. End With
  757. xlSheet.Range("A1:E1").Select()
  758. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  759. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  760. End With : myExcel.Selection.Merge
  761. xlSheet.Range("D2,E2").Select()
  762. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  763. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  764. End With
  765. xlSheet.Range("A" & N2 & ":C" & N2).Select()
  766. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  767. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  768. End With : myExcel.Selection.Merge
  769. xlSheet.Range("A" & N2 + 1 & ":C" & N2 + 1).Select()
  770. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  771. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  772. End With : myExcel.Selection.Merge
  773. xlSheet.Range("D" & N2 + 1 & ":E" & N2 + 1).Select()
  774. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  775. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  776. End With : myExcel.Selection.Merge
  777. For i As Integer = 1 To N2 + 1
  778. xlSheet.Rows(i).AutoFit : xlSheet.Rows(i).RowHeight = xlSheet.Rows(i).RowHeight + 4
  779. Next
  780. End Sub
  781. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet, ByVal allSame As Boolean)
  782. xlSheet.Activate() : xlSheet.Parent.Windows(1).View = XlWindowView.xlPageLayoutView : xlSheet.Cells.Select()
  783. With myExcel.Selection.Font : .Name = "標楷體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  784. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  785. End With
  786. xlSheet.Range("A2:J" & N2 + 3).Select()
  787. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  788. With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  789. With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  790. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  791. With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  792. With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  793. With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  794. myExcel.Application.PrintCommunication = False
  795. With myExcel.ActiveSheet.PageSetup : .PrintTitleRows = "" : .PrintTitleColumns = "" : End With
  796. myExcel.Application.PrintCommunication = True : myExcel.ActiveSheet.PageSetup.PrintArea = "" : myExcel.Application.PrintCommunication = False
  797. With myExcel.ActiveSheet.PageSetup : .LeftHeader = "" : .CenterHeader = "" : .RightHeader = "" : .LeftFooter = "" : .CenterFooter = "" : .RightFooter = ""
  798. .LeftMargin = myExcel.Application.InchesToPoints(0.25) : .RightMargin = myExcel.Application.InchesToPoints(0.25) : .TopMargin = myExcel.Application.InchesToPoints(0.75)
  799. .BottomMargin = myExcel.Application.InchesToPoints(0.75) : .HeaderMargin = myExcel.Application.InchesToPoints(0.3) : .FooterMargin = myExcel.Application.InchesToPoints(0.3)
  800. .PrintHeadings = False : .PrintGridlines = False : .CenterHorizontally = False : .CenterVertically = False : .Draft = False : .FirstPageNumber = xlAutomatic
  801. .BlackAndWhite = False : .Zoom = False : .FitToPagesWide = 1 : .FitToPagesTall = 0 : .OddAndEvenPagesHeaderFooter = False : .DifferentFirstPageHeaderFooter = False
  802. .ScaleWithDocHeaderFooter = True : .AlignMarginsHeaderFooter = True
  803. .EvenPage.LeftHeader.Text = "" : .EvenPage.CenterHeader.Text = "" : .EvenPage.RightHeader.Text = "" : .EvenPage.LeftFooter.Text = "" : .EvenPage.CenterFooter.Text = ""
  804. .EvenPage.RightFooter.Text = "" : .FirstPage.LeftHeader.Text = "" : .FirstPage.CenterHeader.Text = "" : .FirstPage.RightHeader.Text = "" : .FirstPage.LeftFooter.Text = ""
  805. .FirstPage.CenterFooter.Text = "" : .FirstPage.RightFooter.Text = ""
  806. End With : myExcel.Application.PrintCommunication = True
  807. xlSheet.Columns("A:A").ColumnWidth = 5 : xlSheet.Columns("B:B").ColumnWidth = 3 : xlSheet.Columns("C:C").ColumnWidth = 16 : xlSheet.Columns("D:D").ColumnWidth = 13
  808. xlSheet.Columns("E:E").ColumnWidth = 13 : xlSheet.Columns("F:F").ColumnWidth = 13 : xlSheet.Columns("G:G").ColumnWidth = 9 : xlSheet.Columns("H:H").ColumnWidth = 4
  809. xlSheet.Columns("I:I").ColumnWidth = 11 : xlSheet.Columns("J:J").ColumnWidth = 5 : xlSheet.Columns("K:K").WrapText = True
  810. If allSame Then
  811. If 顯示單據_cb.Checked = True Then : xlSheet.Columns("K:K").ColumnWidth = 56.88 : Else : xlSheet.Columns("K:K").ColumnWidth = 66.5 : End If
  812. Else
  813. If 顯示單據_cb.Checked = True Then : xlSheet.Columns("K:K").ColumnWidth = 40.25 : Else : xlSheet.Columns("K:K").ColumnWidth = 49.88 : End If
  814. End If
  815. xlSheet.Rows(N2 + 3 & ":" & N2 + 3).RowHeight = 100
  816. xlSheet.Range("A1:J1").Select()
  817. With myExcel.Selection.Font : .Name = "標楷體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  818. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone
  819. End With
  820. xlSheet.Range("A1:J1").Select()
  821. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  822. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  823. End With : myExcel.Selection.Merge
  824. xlSheet.Range("A2:A3").Select()
  825. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  826. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  827. End With : myExcel.Selection.Merge
  828. xlSheet.Range("B2:B3").Select()
  829. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  830. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  831. End With : myExcel.Selection.Merge
  832. If 顯示單據_cb.Checked = True Then
  833. xlSheet.Range("C2:F3").Select()
  834. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  835. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  836. End With : myExcel.Selection.Merge
  837. xlSheet.Range("G2:G3").Select()
  838. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  839. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  840. End With : myExcel.Selection.Merge
  841. Else
  842. xlSheet.Range("C2:G3").Select()
  843. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  844. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  845. End With : myExcel.Selection.Merge
  846. End If
  847. xlSheet.Range("H2:H3").Select()
  848. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  849. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  850. End With : myExcel.Selection.Merge
  851. xlSheet.Range("I2:I3").Select()
  852. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  853. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  854. End With : myExcel.Selection.Merge
  855. xlSheet.Range("J4:J" & N2 + 1).Select()
  856. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  857. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  858. End With : myExcel.Selection.Merge
  859. xlSheet.Range("A4:A" & N2 + 1).Select()
  860. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  861. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  862. End With : myExcel.Selection.Merge
  863. xlSheet.Rows(2).AutoFit : xlSheet.Rows(2).RowHeight = xlSheet.Rows(2).RowHeight + 1
  864. xlSheet.Rows(3).AutoFit : xlSheet.Rows(3).RowHeight = xlSheet.Rows(3).RowHeight + 1
  865. For i As Integer = 4 To N2
  866. xlSheet.Range("B" & i).Select()
  867. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  868. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  869. End With
  870. xlSheet.Range("H" & i).Select()
  871. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  872. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  873. End With
  874. If allSame Then
  875. If 顯示單據_cb.Checked = True Then
  876. xlSheet.Range("C" & i & ":F" & i).Select()
  877. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  878. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  879. End With : myExcel.Selection.Merge
  880. xlSheet.Range("G" & i).Select()
  881. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  882. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  883. End With
  884. Else
  885. xlSheet.Range("C" & i & ":G" & i).Select()
  886. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  887. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  888. End With : myExcel.Selection.Merge
  889. End If
  890. Else
  891. xlSheet.Range("C" & i).Select()
  892. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  893. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  894. End With : myExcel.Selection.Merge
  895. If 顯示單據_cb.Checked = True Then
  896. xlSheet.Range("D" & i & ":F" & i).Select()
  897. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  898. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  899. End With : myExcel.Selection.Merge
  900. xlSheet.Range("G" & i).Select()
  901. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  902. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  903. End With
  904. Else
  905. xlSheet.Range("D" & i & ":G" & i).Select()
  906. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
  907. .ReadingOrder = xlContext : .MergeCells = False
  908. End With : myExcel.Selection.Merge
  909. End If
  910. End If
  911. xlSheet.Range("I" & i).Select()
  912. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  913. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  914. End With : myExcel.Selection.Merge
  915. xlSheet.Rows(i).AutoFit : xlSheet.Rows(i).RowHeight = xlSheet.Rows(i).RowHeight + 5 : xlSheet.Range("K" & i).Value = ""
  916. Next i
  917. xlSheet.Range("B" & N2 + 1 & ":H" & N2 + 1).Select()
  918. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  919. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  920. End With : myExcel.Selection.Merge
  921. xlSheet.Range("I" & N2 + 1).Select()
  922. With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  923. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  924. End With
  925. xlSheet.Rows(N2 + 1).AutoFit : xlSheet.Rows(N2 + 1).RowHeight = xlSheet.Rows(N2 + 1).RowHeight + 3
  926. xlSheet.Range("A" & N2 + 2 & ":B" & N2 + 2).Select()
  927. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  928. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  929. End With : myExcel.Selection.Merge
  930. xlSheet.Range("G" & N2 + 2 & ":H" & N2 + 2).Select()
  931. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  932. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  933. End With : myExcel.Selection.Merge
  934. xlSheet.Range("I" & N2 + 2 & ":J" & N2 + 2).Select()
  935. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  936. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  937. End With : myExcel.Selection.Merge
  938. xlSheet.Range("A" & N2 + 3 & ":B" & N2 + 3).Select()
  939. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  940. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  941. End With : myExcel.Selection.Merge
  942. xlSheet.Range("G" & N2 + 3 & ":H" & N2 + 3).Select()
  943. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  944. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  945. End With : myExcel.Selection.Merge
  946. xlSheet.Range("I" & N2 + 3 & ":J" & N2 + 3).Select()
  947. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  948. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  949. End With : myExcel.Selection.Merge
  950. xlSheet.Range("J2:J3").Select()
  951. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  952. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  953. End With
  954. xlSheet.Range("C" & N2 + 2 & ":F" & N2 + 2).Select()
  955. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  956. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False
  957. End With
  958. End Sub
  959. Private Sub 公司編號_cb_Click(sender As Object, e As EventArgs) Handles 公司編號_cb.Click
  960. CB選擇清單(公司編號_cb, 公司編號_cb.Text)
  961. End Sub
  962. Private Sub 公司編號_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 公司編號_cb.SelectedIndexChanged
  963. Set_清單1() : Set_清單() : Set_清單2() : 彙總計算() : Set_費用清單()
  964. End Sub
  965. '----------------------滑鼠右鍵--------------------------------------------------------------------------------------------------------------------------------------------------------------------
  966. Private Sub 重新讀取ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 重新讀取ToolStripMenuItem.Click
  967. Set_清單1() : Set_清單() : Set_清單2() : 彙總計算()
  968. End Sub
  969. Private Sub 字體_NUD_ValueChanged(sender As Object, e As EventArgs) Handles 字體_NUD.ValueChanged
  970. 單據彙總_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  971. 財務彙總_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  972. 明細_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 字體_NUD.Value)
  973. End Sub
  974. Private Sub 支付單列印成EXCEL_MouseEnter(sender As Object, e As EventArgs) Handles 支付單列印成EXCEL.MouseEnter
  975. ToolTip1.SetToolTip(Me.支付單列印成EXCEL, "支付單列印成EXCEL")
  976. End Sub
  977. Private Function 大寫轉換(輸入文本 As String) As String
  978. Dim 個位(20), 十位(9), 百位(1), 千位(1), 百萬, 十億, 零, 拾, 百, 仟, 萬, 億, 兆, 答案 As String : Dim 數長 As Integer
  979. 答案 = "" : 零 = "" : 拾 = "" : 百 = "" : 仟 = "" : 萬 = "" : 百萬 = "" : 億 = "" : 十億 = "" : 兆 = ""
  980. 個位(0) = "零" : 個位(1) = "壹" : 個位(2) = "貳" : 個位(3) = "參" : 個位(4) = "肆" : 個位(5) = "伍" : 個位(6) = "陸" : 個位(7) = "柒" : 個位(8) = "捌" : 個位(9) = "玖"
  981. 零 = "零" : 拾 = "拾" : 百 = "百" : 仟 = "仟" : 萬 = "萬" : 億 = "億" : 兆 = "兆"
  982. '--------------轉大寫-----------------------------------------------------------
  983. Dim 位數(13), 末位數 As String
  984. Dim NB As Long = 輸入文本 : Dim NBS As String = NB.ToString() : 數長 = NBS.Length
  985. 位數(1) = Strings.Left(NBS, 1) : 末位數 = Strings.Right(NBS, 1)
  986. If 數長 >= 2 Then : 位數(2) = Strings.Mid(NBS, 2, 1) : End If : If 數長 >= 3 Then : 位數(3) = Strings.Mid(NBS, 3, 1) : End If
  987. If 數長 >= 4 Then : 位數(4) = Strings.Mid(NBS, 4, 1) : End If : If 數長 >= 5 Then : 位數(5) = Strings.Mid(NBS, 5, 1) : End If
  988. If 數長 >= 6 Then : 位數(6) = Strings.Mid(NBS, 6, 1) : End If : If 數長 >= 7 Then : 位數(7) = Strings.Mid(NBS, 7, 1) : End If
  989. If 數長 >= 8 Then : 位數(8) = Strings.Mid(NBS, 8, 1) : End If : If 數長 >= 9 Then : 位數(9) = Strings.Mid(NBS, 9, 1) : End If
  990. If 數長 >= 10 Then : 位數(10) = Strings.Mid(NBS, 10, 1) : End If : If 數長 >= 11 Then : 位數(11) = Strings.Mid(NBS, 11, 1) : End If
  991. If 數長 >= 12 Then : 位數(12) = Strings.Mid(NBS, 12, 1) : End If : If 數長 >= 13 Then : 位數(13) = Strings.Mid(NBS, 13, 1) : End If
  992. If 數長 = 1 Then : 答案 = 個位(輸入文本)
  993. ElseIf 數長 = 2 Then
  994. If 末位數 = "0" Then : 答案 = 個位(位數(1)) & 拾 : Else : 答案 = 個位(位數(1)) & 拾 & 個位(末位數) : End If
  995. ElseIf 數長 = 3 Then : 答案 = 個位(位數(1)) & 百
  996. If 位數(2) = "0" And 末位數 = "0" Then
  997. ElseIf 位數(2) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  998. ElseIf 位數(2) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 拾
  999. ElseIf 位數(2) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 拾 & 個位(末位數)
  1000. End If
  1001. ElseIf 數長 = 4 Then : 答案 = 個位(位數(1)) & 仟
  1002. If 位數(2) = "0" And 位數(3) = "0" And 末位數 = "0" Then
  1003. ElseIf 位數(2) = "0" And 位數(3) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1004. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾 & 個位(末位數)
  1005. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾
  1006. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 百
  1007. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 零 & 個位(末位數)
  1008. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾
  1009. ElseIf 位數(2) <> "0" And 末位數 <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾 & 個位(末位數)
  1010. End If
  1011. ElseIf 數長 = 5 Then : 答案 = 個位(位數(1)) & 萬
  1012. If 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" And 末位數 = "0" Then
  1013. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1014. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾
  1015. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾 & 個位(末位數)
  1016. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(3)) & 百
  1017. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 零 & 個位(末位數)
  1018. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾
  1019. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 個位(末位數)
  1020. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 仟
  1021. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(末位數)
  1022. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(位數(4)) & 拾
  1023. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(位數(4)) & 拾 & 個位(末位數)
  1024. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百
  1025. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 零 & 個位(末位數)
  1026. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾
  1027. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 個位(末位數)
  1028. End If
  1029. ElseIf 數長 = 6 Then
  1030. If 位數(2) = "0" Then : 答案 = 個位(位數(1)) & 拾 & 萬 : Else : 答案 = 個位(位數(1)) & 拾 & 個位(位數(2)) & 萬 : End If
  1031. If 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" And 末位數 = "0" Then
  1032. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1033. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾
  1034. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾 & 個位(末位數)
  1035. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(4)) & 百
  1036. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 零 & 個位(末位數)
  1037. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾
  1038. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 個位(末位數)
  1039. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(3)) & 仟
  1040. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(末位數)
  1041. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(位數(5)) & 拾
  1042. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(位數(5)) & 拾 & 個位(末位數)
  1043. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百
  1044. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 零 & 個位(末位數)
  1045. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾
  1046. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 個位(末位數)
  1047. End If
  1048. ElseIf 數長 = 7 Then : 答案 = 個位(位數(1)) & 百
  1049. If 位數(2) = "0" And 位數(3) = "0" Then : 答案 &= 萬
  1050. ElseIf 位數(2) = "0" And 位數(3) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 萬
  1051. ElseIf 位數(2) <> "0" And 位數(3) = "0" Then : 答案 &= 個位(位數(2)) & 拾 & 萬
  1052. ElseIf 位數(2) <> "0" And 位數(3) <> "0" Then : 答案 &= 個位(位數(2)) & 拾 & 個位(位數(3)) & 萬
  1053. End If
  1054. If 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" And 末位數 = "0" Then
  1055. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1056. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(6)) & 拾
  1057. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 拾 & 個位(末位數)
  1058. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(5)) & 百
  1059. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 零 & 個位(末位數)
  1060. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾
  1061. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 個位(末位數)
  1062. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(4)) & 仟
  1063. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(末位數)
  1064. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(位數(6)) & 拾
  1065. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(位數(6)) & 拾 & 個位(末位數)
  1066. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百
  1067. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 零 & 個位(末位數)
  1068. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾
  1069. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 個位(末位數)
  1070. End If
  1071. ElseIf 數長 = 8 Then : 答案 = 個位(位數(1)) & 仟
  1072. If 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" Then : 答案 &= 萬
  1073. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 萬
  1074. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾 & 個位(位數(4)) & 萬
  1075. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾 & 萬
  1076. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" Then : 答案 &= 個位(位數(2)) & 百 & 萬
  1077. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 零 & 個位(位數(4)) & 萬
  1078. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾 & 萬
  1079. ElseIf 位數(2) <> "0" And 位數(4) <> "0" And 位數(4) <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾 & 個位(位數(4)) & 萬
  1080. End If
  1081. If 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" And 末位數 = "0" Then
  1082. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1083. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(7)) & 拾
  1084. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 拾 & 個位(末位數)
  1085. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(6)) & 百
  1086. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 零 & 個位(末位數)
  1087. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾
  1088. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 個位(末位數)
  1089. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(5)) & 仟
  1090. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(末位數)
  1091. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(位數(7)) & 拾
  1092. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(位數(7)) & 拾 & 個位(末位數)
  1093. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百
  1094. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 零 & 個位(末位數)
  1095. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾
  1096. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 個位(末位數)
  1097. End If
  1098. ElseIf 數長 = 9 Then : 答案 = 個位(位數(1)) & 億
  1099. If 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" Then
  1100. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 萬
  1101. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾 & 萬
  1102. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 萬
  1103. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 萬
  1104. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 零 & 個位(位數(5)) & 萬
  1105. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 萬
  1106. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 萬
  1107. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 萬
  1108. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(位數(5)) & 萬
  1109. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(位數(4)) & 拾 & 萬
  1110. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 零 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 萬
  1111. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 萬
  1112. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 零 & 個位(位數(5)) & 萬
  1113. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 萬
  1114. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(2)) & 仟 & 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 萬
  1115. End If
  1116. If 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" And 末位數 = "0" Then
  1117. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1118. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(8)) & 拾
  1119. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 拾 & 個位(末位數)
  1120. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(7)) & 百
  1121. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 零 & 個位(末位數)
  1122. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾
  1123. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 個位(末位數)
  1124. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(6)) & 仟
  1125. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(末位數)
  1126. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(位數(8)) & 拾
  1127. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(位數(8)) & 拾 & 個位(末位數)
  1128. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百
  1129. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 零 & 個位(末位數)
  1130. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾
  1131. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 個位(末位數)
  1132. End If
  1133. ElseIf 數長 = 10 Then
  1134. If 位數(2) = "0" Then : 答案 = 個位(位數(1)) & 拾 & 億 : Else : 答案 = 個位(位數(1)) & 拾 & 個位(位數(2)) & 億 : End If
  1135. If 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" Then
  1136. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 萬
  1137. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾 & 萬
  1138. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 萬
  1139. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 萬
  1140. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 零 & 個位(位數(6)) & 萬
  1141. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 萬
  1142. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 萬
  1143. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 萬
  1144. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(位數(6)) & 萬
  1145. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(位數(5)) & 拾 & 萬
  1146. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 零 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 萬
  1147. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 萬
  1148. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 零 & 個位(位數(6)) & 萬
  1149. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 萬
  1150. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(3)) & 仟 & 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 萬
  1151. End If
  1152. If 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" And 末位數 = "0" Then
  1153. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1154. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(9)) & 拾
  1155. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(9)) & 拾 & 個位(末位數)
  1156. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(8)) & 百
  1157. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 零 & 個位(末位數)
  1158. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾
  1159. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 個位(末位數)
  1160. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(7)) & 仟
  1161. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(末位數)
  1162. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(位數(9)) & 拾
  1163. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(位數(9)) & 拾 & 個位(末位數)
  1164. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百
  1165. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 零 & 個位(末位數)
  1166. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾
  1167. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 個位(末位數)
  1168. End If
  1169. ElseIf 數長 = 11 Then : 答案 = 個位(位數(1)) & 百
  1170. If 位數(2) = "0" And 位數(3) = "0" Then : 答案 &= 億
  1171. ElseIf 位數(2) = "0" And 位數(3) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 億
  1172. ElseIf 位數(2) <> "0" And 位數(3) = "0" Then : 答案 &= 個位(位數(2)) & 拾 & 億
  1173. ElseIf 位數(2) <> "0" And 位數(3) <> "0" Then : 答案 &= 個位(位數(2)) & 拾 & 個位(位數(3)) & 億
  1174. End If
  1175. If 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" Then
  1176. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 萬
  1177. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" Then : 答案 &= 零 & 個位(位數(6)) & 拾 & 萬
  1178. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 拾 & 個位(位數(7)) & 萬
  1179. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 萬
  1180. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 零 & 個位(位數(7)) & 萬
  1181. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 萬
  1182. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 個位(位數(7)) & 萬
  1183. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 萬
  1184. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(位數(7)) & 萬
  1185. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(位數(6)) & 拾 & 萬
  1186. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 零 & 個位(位數(6)) & 拾 & 個位(位數(7)) & 萬
  1187. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 萬
  1188. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 零 & 個位(位數(7)) & 萬
  1189. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 萬
  1190. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" Then : 答案 &= 個位(位數(4)) & 仟 & 個位(位數(5)) & 百 & 個位(位數(6)) & 拾 & 個位(位數(7)) & 萬
  1191. End If
  1192. If 位數(8) = "0" And 位數(9) = "0" And 位數(10) = "0" And 末位數 = "0" Then
  1193. ElseIf 位數(8) = "0" And 位數(9) = "0" And 位數(10) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1194. ElseIf 位數(8) = "0" And 位數(9) = "0" And 位數(10) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(10)) & 拾
  1195. ElseIf 位數(8) = "0" And 位數(9) = "0" And 位數(10) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(10)) & 拾 & 個位(末位數)
  1196. ElseIf 位數(8) = "0" And 位數(9) <> "0" And 位數(10) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(9)) & 百
  1197. ElseIf 位數(8) = "0" And 位數(9) <> "0" And 位數(10) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(9)) & 百 & 零 & 個位(末位數)
  1198. ElseIf 位數(8) = "0" And 位數(9) <> "0" And 位數(10) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(9)) & 百 & 個位(位數(10)) & 拾
  1199. ElseIf 位數(8) = "0" And 位數(9) <> "0" And 位數(10) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(9)) & 百 & 個位(位數(10)) & 拾 & 個位(末位數)
  1200. ElseIf 位數(8) <> "0" And 位數(9) = "0" And 位數(10) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(8)) & 仟
  1201. ElseIf 位數(8) <> "0" And 位數(9) = "0" And 位數(10) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(8)) & 仟 & 零 & 個位(末位數)
  1202. ElseIf 位數(8) <> "0" And 位數(9) = "0" And 位數(10) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(8)) & 仟 & 零 & 個位(位數(10)) & 拾
  1203. ElseIf 位數(8) <> "0" And 位數(9) = "0" And 位數(10) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(8)) & 仟 & 零 & 個位(位數(10)) & 拾 & 個位(末位數)
  1204. ElseIf 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(8)) & 仟 & 個位(位數(9)) & 百
  1205. ElseIf 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(8)) & 仟 & 個位(位數(9)) & 百 & 零 & 個位(末位數)
  1206. ElseIf 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(8)) & 仟 & 個位(位數(9)) & 百 & 個位(位數(10)) & 拾
  1207. ElseIf 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(8)) & 仟 & 個位(位數(9)) & 百 & 個位(位數(10)) & 拾 & 個位(末位數)
  1208. End If
  1209. ElseIf 數長 = 12 Then : 答案 = 個位(位數(1)) & 仟
  1210. If 位數(2) = "0" And 位數(3) = "0" And 位數(4) = "0" Then : 答案 &= 億
  1211. ElseIf 位數(2) = "0" And 位數(3) = "0" And 位數(4) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 億
  1212. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) <> "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾 & 個位(位數(4)) & 億
  1213. ElseIf 位數(2) = "0" And 位數(3) <> "0" And 位數(4) = "0" Then : 答案 &= 零 & 個位(位數(3)) & 拾 & 億
  1214. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) = "0" Then : 答案 &= 個位(位數(2)) & 百 & 億
  1215. ElseIf 位數(2) <> "0" And 位數(3) = "0" And 位數(4) <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 零 & 個位(位數(4)) & 億
  1216. ElseIf 位數(2) <> "0" And 位數(3) <> "0" And 位數(4) = "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾 & 億
  1217. ElseIf 位數(2) <> "0" And 位數(4) <> "0" And 位數(4) <> "0" Then : 答案 &= 個位(位數(2)) & 百 & 個位(位數(3)) & 拾 & 個位(位數(4)) & 億
  1218. End If
  1219. If 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" Then
  1220. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 萬
  1221. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" Then : 答案 &= 零 & 個位(位數(7)) & 拾 & 萬
  1222. ElseIf 位數(5) = "0" And 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 拾 & 個位(位數(8)) & 萬
  1223. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 萬
  1224. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 零 & 個位(位數(8)) & 萬
  1225. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 萬
  1226. ElseIf 位數(5) = "0" And 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 個位(位數(8)) & 萬
  1227. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 萬
  1228. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(位數(8)) & 萬
  1229. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(位數(7)) & 拾 & 萬
  1230. ElseIf 位數(5) <> "0" And 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 零 & 個位(位數(7)) & 拾 & 個位(位數(8)) & 萬
  1231. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 萬
  1232. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 零 & 個位(位數(8)) & 萬
  1233. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 萬
  1234. ElseIf 位數(5) <> "0" And 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" Then : 答案 &= 個位(位數(5)) & 仟 & 個位(位數(6)) & 百 & 個位(位數(7)) & 拾 & 個位(位數(8)) & 萬
  1235. End If
  1236. If 位數(9) = "0" And 位數(10) = "0" And 位數(11) = "0" And 末位數 = "0" Then
  1237. ElseIf 位數(9) = "0" And 位數(10) = "0" And 位數(11) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1238. ElseIf 位數(9) = "0" And 位數(10) = "0" And 位數(11) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(11)) & 拾
  1239. ElseIf 位數(9) = "0" And 位數(10) = "0" And 位數(11) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(11)) & 拾 & 個位(末位數)
  1240. ElseIf 位數(9) = "0" And 位數(10) <> "0" And 位數(11) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(10)) & 百
  1241. ElseIf 位數(9) = "0" And 位數(10) <> "0" And 位數(11) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(10)) & 百 & 零 & 個位(末位數)
  1242. ElseIf 位數(9) = "0" And 位數(10) <> "0" And 位數(11) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(10)) & 百 & 個位(位數(11)) & 拾
  1243. ElseIf 位數(9) = "0" And 位數(10) <> "0" And 位數(11) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(10)) & 百 & 個位(位數(11)) & 拾 & 個位(末位數)
  1244. ElseIf 位數(9) <> "0" And 位數(10) = "0" And 位數(11) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(9)) & 仟
  1245. ElseIf 位數(9) <> "0" And 位數(10) = "0" And 位數(11) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(9)) & 仟 & 零 & 個位(末位數)
  1246. ElseIf 位數(9) <> "0" And 位數(10) = "0" And 位數(11) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(9)) & 仟 & 零 & 個位(位數(11)) & 拾
  1247. ElseIf 位數(9) <> "0" And 位數(10) = "0" And 位數(11) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(9)) & 仟 & 零 & 個位(位數(11)) & 拾 & 個位(末位數)
  1248. ElseIf 位數(9) <> "0" And 位數(10) <> "0" And 位數(11) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(9)) & 仟 & 個位(位數(10)) & 百
  1249. ElseIf 位數(9) <> "0" And 位數(10) <> "0" And 位數(11) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(9)) & 仟 & 個位(位數(10)) & 百 & 零 & 個位(末位數)
  1250. ElseIf 位數(9) <> "0" And 位數(10) <> "0" And 位數(11) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(9)) & 仟 & 個位(位數(10)) & 百 & 個位(位數(11)) & 拾
  1251. ElseIf 位數(9) <> "0" And 位數(10) <> "0" And 位數(11) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(9)) & 仟 & 個位(位數(10)) & 百 & 個位(位數(11)) & 拾 & 個位(末位數)
  1252. End If
  1253. ElseIf 數長 = 13 Then : 答案 = 個位(位數(1)) & 兆 : 答案 &= 個位(位數(2)) & 仟
  1254. If 位數(3) = "0" And 位數(4) = "0" And 位數(5) = "0" Then : 答案 &= 億
  1255. ElseIf 位數(3) = "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 億
  1256. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) <> "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 億
  1257. ElseIf 位數(3) = "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 零 & 個位(位數(4)) & 拾 & 億
  1258. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(3)) & 百 & 億
  1259. ElseIf 位數(3) <> "0" And 位數(4) = "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(3)) & 百 & 零 & 個位(位數(5)) & 億
  1260. ElseIf 位數(3) <> "0" And 位數(4) <> "0" And 位數(5) = "0" Then : 答案 &= 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 億
  1261. ElseIf 位數(3) <> "0" And 位數(5) <> "0" And 位數(5) <> "0" Then : 答案 &= 個位(位數(3)) & 百 & 個位(位數(4)) & 拾 & 個位(位數(5)) & 億
  1262. End If
  1263. If 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" Then
  1264. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" Then : 答案 &= 零 & 個位(位數(9)) & 萬
  1265. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" Then : 答案 &= 零 & 個位(位數(8)) & 拾 & 萬
  1266. ElseIf 位數(6) = "0" And 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 拾 & 個位(位數(9)) & 萬
  1267. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 萬
  1268. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 零 & 個位(位數(9)) & 萬
  1269. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 萬
  1270. ElseIf 位數(6) = "0" And 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" Then : 答案 &= 零 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 個位(位數(9)) & 萬
  1271. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 萬
  1272. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(位數(9)) & 萬
  1273. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(位數(8)) & 拾 & 萬
  1274. ElseIf 位數(6) <> "0" And 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 零 & 個位(位數(8)) & 拾 & 個位(位數(9)) & 萬
  1275. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 萬
  1276. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 零 & 個位(位數(9)) & 萬
  1277. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 萬
  1278. ElseIf 位數(6) <> "0" And 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" Then : 答案 &= 個位(位數(6)) & 仟 & 個位(位數(7)) & 百 & 個位(位數(8)) & 拾 & 個位(位數(9)) & 萬
  1279. End If
  1280. If 位數(10) = "0" And 位數(11) = "0" And 位數(12) = "0" And 末位數 = "0" Then
  1281. ElseIf 位數(10) = "0" And 位數(11) = "0" And 位數(12) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1282. ElseIf 位數(10) = "0" And 位數(11) = "0" And 位數(12) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(12)) & 拾
  1283. ElseIf 位數(10) = "0" And 位數(11) = "0" And 位數(12) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(12)) & 拾 & 個位(末位數)
  1284. ElseIf 位數(10) = "0" And 位數(11) <> "0" And 位數(12) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(11)) & 百
  1285. ElseIf 位數(10) = "0" And 位數(11) <> "0" And 位數(12) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(11)) & 百 & 零 & 個位(末位數)
  1286. ElseIf 位數(10) = "0" And 位數(11) <> "0" And 位數(12) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(11)) & 百 & 個位(位數(12)) & 拾
  1287. ElseIf 位數(10) = "0" And 位數(11) <> "0" And 位數(12) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(11)) & 百 & 個位(位數(12)) & 拾 & 個位(末位數)
  1288. ElseIf 位數(10) <> "0" And 位數(11) = "0" And 位數(12) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(10)) & 仟
  1289. ElseIf 位數(10) <> "0" And 位數(11) = "0" And 位數(12) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(10)) & 仟 & 零 & 個位(末位數)
  1290. ElseIf 位數(10) <> "0" And 位數(11) = "0" And 位數(12) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(10)) & 仟 & 零 & 個位(位數(12)) & 拾
  1291. ElseIf 位數(10) <> "0" And 位數(11) = "0" And 位數(12) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(10)) & 仟 & 零 & 個位(位數(12)) & 拾 & 個位(末位數)
  1292. ElseIf 位數(10) <> "0" And 位數(11) <> "0" And 位數(12) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(10)) & 仟 & 個位(位數(11)) & 百
  1293. ElseIf 位數(10) <> "0" And 位數(11) <> "0" And 位數(12) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(10)) & 仟 & 個位(位數(11)) & 百 & 零 & 個位(末位數)
  1294. ElseIf 位數(10) <> "0" And 位數(11) <> "0" And 位數(12) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(10)) & 仟 & 個位(位數(11)) & 百 & 個位(位數(12)) & 拾
  1295. ElseIf 位數(10) <> "0" And 位數(11) <> "0" And 位數(12) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(10)) & 仟 & 個位(位數(11)) & 百 & 個位(位數(12)) & 拾 & 個位(末位數)
  1296. End If
  1297. ElseIf 數長 = 14 Then
  1298. If 位數(2) = "0" Then : 答案 = 個位(位數(1)) & 拾 & 兆 : Else : 答案 = 個位(位數(1)) & 拾 & 個位(位數(2)) & 兆 : End If : 答案 &= 個位(位數(3)) & 仟
  1299. If 位數(4) = "0" And 位數(5) = "0" And 位數(6) = "0" Then : 答案 &= 億
  1300. ElseIf 位數(4) = "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(6)) & 億
  1301. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) <> "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 億
  1302. ElseIf 位數(4) = "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 零 & 個位(位數(5)) & 拾 & 億
  1303. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(4)) & 百 & 億
  1304. ElseIf 位數(4) <> "0" And 位數(5) = "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(4)) & 百 & 零 & 個位(位數(6)) & 億
  1305. ElseIf 位數(4) <> "0" And 位數(5) <> "0" And 位數(6) = "0" Then : 答案 &= 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 億
  1306. ElseIf 位數(4) <> "0" And 位數(6) <> "0" And 位數(6) <> "0" Then : 答案 &= 個位(位數(4)) & 百 & 個位(位數(5)) & 拾 & 個位(位數(6)) & 億
  1307. End If
  1308. If 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" And 位數(10) = "0" Then
  1309. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) = "0" And 位數(10) <> "0" Then : 答案 &= 零 & 個位(位數(10)) & 萬
  1310. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" And 位數(10) = "0" Then : 答案 &= 零 & 個位(位數(9)) & 拾 & 萬
  1311. ElseIf 位數(7) = "0" And 位數(8) = "0" And 位數(9) <> "0" And 位數(10) <> "0" Then : 答案 &= 零 & 個位(位數(9)) & 拾 & 個位(位數(10)) & 萬
  1312. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" And 位數(10) = "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 萬
  1313. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) = "0" And 位數(10) <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 零 & 個位(位數(10)) & 萬
  1314. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) = "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 萬
  1315. ElseIf 位數(7) = "0" And 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) <> "0" Then : 答案 &= 零 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 個位(位數(10)) & 萬
  1316. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" And 位數(10) = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 萬
  1317. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) = "0" And 位數(10) <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(位數(10)) & 萬
  1318. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" And 位數(10) = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(位數(9)) & 拾 & 萬
  1319. ElseIf 位數(7) <> "0" And 位數(8) = "0" And 位數(9) <> "0" And 位數(10) <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 零 & 個位(位數(9)) & 拾 & 個位(位數(10)) & 萬
  1320. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" And 位數(10) = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 萬
  1321. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) = "0" And 位數(10) <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 零 & 個位(位數(10)) & 萬
  1322. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) = "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 萬
  1323. ElseIf 位數(7) <> "0" And 位數(8) <> "0" And 位數(9) <> "0" And 位數(10) <> "0" Then : 答案 &= 個位(位數(7)) & 仟 & 個位(位數(8)) & 百 & 個位(位數(9)) & 拾 & 個位(位數(10)) & 萬
  1324. End If
  1325. If 位數(11) = "0" And 位數(12) = "0" And 位數(13) = "0" And 末位數 = "0" Then
  1326. ElseIf 位數(11) = "0" And 位數(12) = "0" And 位數(13) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(末位數)
  1327. ElseIf 位數(11) = "0" And 位數(12) = "0" And 位數(13) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(13)) & 拾
  1328. ElseIf 位數(11) = "0" And 位數(12) = "0" And 位數(13) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(13)) & 拾 & 個位(末位數)
  1329. ElseIf 位數(11) = "0" And 位數(12) <> "0" And 位數(13) = "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(12)) & 百
  1330. ElseIf 位數(11) = "0" And 位數(12) <> "0" And 位數(13) = "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(12)) & 百 & 零 & 個位(末位數)
  1331. ElseIf 位數(11) = "0" And 位數(12) <> "0" And 位數(13) <> "0" And 末位數 = "0" Then : 答案 &= 零 & 個位(位數(12)) & 百 & 個位(位數(13)) & 拾
  1332. ElseIf 位數(11) = "0" And 位數(12) <> "0" And 位數(13) <> "0" And 末位數 <> "0" Then : 答案 &= 零 & 個位(位數(12)) & 百 & 個位(位數(13)) & 拾 & 個位(末位數)
  1333. ElseIf 位數(11) <> "0" And 位數(12) = "0" And 位數(13) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(11)) & 仟
  1334. ElseIf 位數(11) <> "0" And 位數(12) = "0" And 位數(13) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(11)) & 仟 & 零 & 個位(末位數)
  1335. ElseIf 位數(11) <> "0" And 位數(12) = "0" And 位數(13) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(11)) & 仟 & 零 & 個位(位數(13)) & 拾
  1336. ElseIf 位數(11) <> "0" And 位數(12) = "0" And 位數(13) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(11)) & 仟 & 零 & 個位(位數(13)) & 拾 & 個位(末位數)
  1337. ElseIf 位數(11) <> "0" And 位數(12) <> "0" And 位數(13) = "0" And 末位數 = "0" Then : 答案 &= 個位(位數(11)) & 仟 & 個位(位數(12)) & 百
  1338. ElseIf 位數(11) <> "0" And 位數(12) <> "0" And 位數(13) = "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(11)) & 仟 & 個位(位數(12)) & 百 & 零 & 個位(末位數)
  1339. ElseIf 位數(11) <> "0" And 位數(12) <> "0" And 位數(13) <> "0" And 末位數 = "0" Then : 答案 &= 個位(位數(11)) & 仟 & 個位(位數(12)) & 百 & 個位(位數(13)) & 拾
  1340. ElseIf 位數(11) <> "0" And 位數(12) <> "0" And 位數(13) <> "0" And 末位數 <> "0" Then : 答案 &= 個位(位數(11)) & 仟 & 個位(位數(12)) & 百 & 個位(位數(13)) & 拾 & 個位(末位數)
  1341. End If
  1342. End If
  1343. Return 答案
  1344. End Function
  1345. End Class