No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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

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