Brak opisu
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 129KB

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