Ei kuvausta
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 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. Option Strict Off
  2. Imports System.Text.RegularExpressions
  3. Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
  4. Imports Microsoft.Office.Interop.Excel.Constants
  5. Imports Microsoft.Office.Interop.Excel.XlBordersIndex
  6. Imports Microsoft.Office.Interop.Excel.XlLineStyle
  7. Imports Microsoft.Office.Interop.Excel.XlBorderWeight
  8. Imports Microsoft.Office.Interop.Excel.XlThemeFont
  9. Imports Microsoft.Office.Interop.Excel.XlThemeColor
  10. Imports Microsoft.Office.Interop.Excel.XlWindowState
  11. Imports Microsoft.Office.Interop.Excel
  12. Public Class 樣品標籤批量列印
  13. Private ReadOnly ds, ds1, ds2, ds4, ds5, ds6 As New DataSet
  14. Dim DDFF, BBNN11, AAWW, HHGG, X1, X2 As String
  15. Private ReadOnly RRTT As New Regex("[\u4e00-\u9fa5]")
  16. Dim N1, N2, N3, BBNN1 As Integer
  17. Dim 已超出 As Boolean
  18. Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
  19. Private Sub Set_DGV3載入前設定()
  20. 主表單_dgv.DataSource = Nothing : ds2.Clear()
  21. 主表單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  22. 主表單_dgv.ColumnHeadersHeight = 25
  23. 主表單_dgv.AllowUserToAddRows = False
  24. End Sub
  25. Private Sub Set_DGV3載入後設定()
  26. da.Fill(ds2) : 主表單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  27. Set_grid2()
  28. End Sub
  29. Private Sub Set_清單2()
  30. Set_DGV3載入前設定()
  31. SQL_主表單()
  32. Set_DGV3載入後設定()
  33. End Sub
  34. Private Sub Set_grid2()
  35. 主表單_dgv.Columns(0).Width = 60 : 主表單_dgv.Columns(1).Width = 150 : 主表單_dgv.Columns(2).Width = 150 : 主表單_dgv.Columns(3).Width = 150 : 主表單_dgv.Columns(4).Width = 150
  36. 主表單_dgv.Columns(5).Width = 150 : 主表單_dgv.Columns(6).Width = 150 : 主表單_dgv.Columns(7).Width = 150 : 主表單_dgv.Columns(8).Width = 150 : 主表單_dgv.Columns(9).Width = 303
  37. 主表單_dgv.Columns(10).Width = 302 : 主表單_dgv.Columns(11).Visible = False
  38. 主表單_dgv.Columns(7).DefaultCellStyle.Format = "#,##0.0"
  39. 主表單_dgv.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  40. 主表單_dgv.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  41. 主表單_dgv.EditMode = DataGridViewEditMode.EditOnEnter
  42. For i As Integer = 0 To 主表單_dgv.Rows.Count - 1 : 主表單_dgv.Rows(i).Cells("選擇").Value = False : Next i
  43. For i As Integer = 0 To 主表單_dgv.Rows.Count - 1
  44. 資料數 = 主表單_dgv.Rows.Count : MyModule1.進度條()
  45. PA = 主表單_dgv.Rows(i).Cells("流水號").Value
  46. SQL_一筆材料名稱()
  47. If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
  48. '--------------------------------------------------------------------------------------------
  49. BBNN1 = DDFF.Length.ToString()
  50. For II As Integer = 0 To BBNN1 - 1
  51. If II = 0 Then
  52. AAWW = Strings.Left(DDFF, 1)
  53. If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
  54. Else
  55. AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
  56. End If
  57. Next : 主表單_dgv.Rows(i).Cells("面料").Value = BBNN11
  58. '--------------------------------------------------------------------------------------------
  59. SQL_一筆材料名稱1()
  60. If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
  61. '--------------------------------------------------------------------------------------------
  62. BBNN1 = DDFF.Length.ToString()
  63. For II As Integer = 0 To BBNN1 - 1
  64. If II = 0 Then
  65. AAWW = Strings.Left(DDFF, 1)
  66. If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
  67. Else
  68. AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
  69. End If
  70. Next : 主表單_dgv.Rows(i).Cells("大底").Value = BBNN11
  71. '--------------------------------------------------------------------------------------------
  72. Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  73. End Sub
  74. Private Sub ComboBox1下拉表單資料載入()
  75. SQL_季節清單()
  76. 季節_cb.Items.Clear() : While (dr.Read()) : 季節_cb.Items.Add(dr("SEASON")) : End While : conn.Close()
  77. End Sub
  78. Private Sub ComboBox2下拉表單資料載入()
  79. SQL_客戶簡稱()
  80. 季節1_cb.Items.Clear() : While (dr.Read()) : 季節1_cb.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
  81. End Sub
  82. Private Sub 樣品標籤批量列印_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  83. WINPROFIT_ERP_SYS.WindowState = 2 : Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  84. ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入()
  85. End Sub
  86. Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 主表單_dgv.RowPostPaint
  87. Dim linePen As New Pen(Color.Blue, 2)
  88. If e.RowIndex = 主表單_dgv.Rows.Count - 1 Then
  89. Exit Sub
  90. Else
  91. If 主表單_dgv(2, e.RowIndex).Value.ToString <> 主表單_dgv(2, e.RowIndex + 1).Value.ToString Then
  92. Dim startX As Integer = IIf(主表單_dgv.RowHeadersVisible, 主表單_dgv.RowHeadersWidth, 0)
  93. Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
  94. Dim endX As Integer = startX + 主表單_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 主表單_dgv.HorizontalScrollingOffset
  95. e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
  96. Exit Sub
  97. End If
  98. End If
  99. End Sub
  100. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 季節_cb.SelectedIndexChanged
  101. If 季節_cb.Text <> "" And 季節1_cb.Text <> "" Then : Set_清單2() : End If
  102. End Sub
  103. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 季節1_cb.SelectedIndexChanged
  104. If 季節_cb.Text <> "" And 季節1_cb.Text <> "" Then : Set_清單2() : End If
  105. End Sub
  106. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles 全部選擇_bt.Click
  107. For i As Integer = 0 To 主表單_dgv.Rows.Count - 1 : 主表單_dgv.Rows(i).Cells("選擇").Value = True : Next i
  108. End Sub
  109. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles 全部取消_bt.Click
  110. For i As Integer = 0 To 主表單_dgv.Rows.Count - 1 : 主表單_dgv.Rows(i).Cells("選擇").Value = False : Next i
  111. End Sub
  112. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
  113. xlApp = CType(CreateObject("Excel.Application"), Application)
  114. xlBook = xlApp.Workbooks.Add
  115. xlApp.DisplayAlerts = True
  116. xlBook.Activate()
  117. xlSheet = NewMethod(xlBook)
  118. xlSheet.Activate()
  119. xlApp.Visible = True
  120. xlApp.Application.WindowState = xlMaximized
  121. N1 = 0 : N2 = 0 : N3 = 0
  122. For i As Integer = 0 To 主表單_dgv.Rows.Count - 1
  123. For ii As Integer = 1 To 主表單_dgv.Rows(i).Cells("數量").Value * 2
  124. If 主表單_dgv.Rows(i).Cells("選擇").Value = True Then
  125. If 主表單_dgv.Rows(i).Cells("數量").Value <> 0 Then
  126. xlSheet.Cells(1 + N1, 1 + N3) = " ME TOO"
  127. xlSheet.Cells(2 + N1, 1 + N3) = " " & 樣品進度表分類5
  128. xlSheet.Cells(3 + N1, 1 + N3) = "Season" : xlSheet.Cells(3 + N1, 2 + N3) = 季節_cb.Text
  129. xlSheet.Cells(4 + N1, 1 + N3) = "Customer:" : xlSheet.Cells(4 + N1, 2 + N3) = 季節1_cb.Text
  130. xlSheet.Cells(5 + N1, 1 + N3) = "Styie#/Name:"
  131. xlSheet.Cells(5 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(6 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("型體名稱").Value
  132. xlSheet.Cells(7 + N1, 1 + N3) = "Last/Const:" : xlSheet.Cells(7 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("模具編號").Value
  133. xlSheet.Cells(8 + N1, 1 + N3) = "Upper Mtrl:" : xlSheet.Cells(8 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("面料").Value
  134. xlSheet.Cells(9 + N1, 1 + N3) = "Color:" : xlSheet.Cells(9 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("顏色").Value
  135. xlSheet.Cells(10 + N1, 1 + N3) = "Outsole:" : xlSheet.Cells(10 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("大底").Value
  136. xlSheet.Cells(11 + N1, 1 + N3) = "Size:" : xlSheet.Cells(11 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("SIZE").Value
  137. xlSheet.Cells(12 + N1, 1 + N3) = "Date:" : xlSheet.Cells(12 + N1, 2 + N3) = 主表單_dgv.Rows(i).Cells("ETD").Value
  138. AA(xlApp, xlSheet)
  139. N1 += 12 : N2 += 1
  140. If N2 = 100 Or N2 = 200 Or N2 = 300 Or N2 = 400 Or N2 = 500 Or N2 = 600 Or N2 = 700 Or N2 = 800 Or N2 = 900 Or N2 = 1000 Or N2 = 1100 Or N2 = 1200 Or N2 = 1300 Or N2 = 1400 Or N2 = 1500 Or
  141. N2 = 1600 Or N2 = 1700 Or N2 = 1800 Or N2 = 1900 Or N2 = 2000 Or N2 = 2100 Or N2 = 2200 Or N2 = 2300 Or N2 = 2400 Or N2 = 2500 Or N2 = 2600 Or N2 = 2700 Or N2 = 2800 Or N2 = 2900 Or
  142. N2 = 3000 Or N2 = 3100 Or N2 = 3200 Then
  143. N3 += 2 : N1 = 0
  144. End If
  145. End If
  146. End If
  147. Next
  148. Next i
  149. BB(xlApp, xlSheet)
  150. xlSheet.PageSetup.PrintArea = ""
  151. xlApp.Cells.Select()
  152. xlSheet.Range("B1").Select()
  153. xlApp.Application.WindowState = xlMinimized
  154. MsgBox("列印完成")
  155. End Sub
  156. Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
  157. Return CType(xlBook.Worksheets.Add, Worksheet)
  158. End Function
  159. Private Sub 分行()
  160. If N2 = 0 Then : X1 = "A" : X2 = "B" : ElseIf N2 = 100 Then : X1 = "C" : X2 = "D" : ElseIf N2 = 200 Then : X1 = "E" : X2 = "F" : ElseIf N2 = 300 Then : X1 = "G" : X2 = "H"
  161. ElseIf N2 = 400 Then : X1 = "I" : X2 = "J" : ElseIf N2 = 500 Then : X1 = "K" : X2 = "L" : ElseIf N2 = 600 Then : X1 = "M" : X2 = "N" : ElseIf N2 = 700 Then : X1 = "O" : X2 = "P"
  162. ElseIf N2 = 800 Then : X1 = "Q" : X2 = "R" : ElseIf N2 = 900 Then : X1 = "S" : X2 = "T" : ElseIf N2 = 1000 Then : X1 = "U" : X2 = "V" : ElseIf N2 = 1100 Then : X1 = "W" : X2 = "X"
  163. ElseIf N2 = 1200 Then : X1 = "Y" : X2 = "Z" : ElseIf N2 = 1300 Then : X1 = "AA" : X2 = "AB" : ElseIf N2 = 1400 Then : X1 = "AC" : X2 = "AD" : ElseIf N2 = 1500 Then : X1 = "AE" : X2 = "AF"
  164. ElseIf N2 = 1600 Then : X1 = "AG" : X2 = "AH" : ElseIf N2 = 1700 Then : X1 = "AI" : X2 = "AJ" : ElseIf N2 = 1800 Then : X1 = "AK" : X2 = "AL" : ElseIf N2 = 1900 Then : X1 = "AM" : X2 = "AN"
  165. ElseIf N2 = 2000 Then : X1 = "AO" : X2 = "AP" : ElseIf N2 = 2100 Then : X1 = "AQ" : X2 = "AR" : ElseIf N2 = 2200 Then : X1 = "AS" : X2 = "AT" : ElseIf N2 = 2300 Then : X1 = "AU" : X2 = "AV"
  166. ElseIf N2 = 2400 Then : X1 = "AW" : X2 = "AX" : ElseIf N2 = 2500 Then : X1 = "AY" : X2 = "AZ" : ElseIf N2 = 2600 Then : X1 = "BA" : X2 = "BB" : ElseIf N2 = 2700 Then : X1 = "BC" : X2 = "BD"
  167. ElseIf N2 = 2800 Then : X1 = "BE" : X2 = "BF" : ElseIf N2 = 2900 Then : X1 = "BG" : X2 = "BH" : ElseIf N2 = 3000 Then : X1 = "BI" : X2 = "BJ" : ElseIf N2 = 3100 Then : X1 = "BK" : X2 = "BL"
  168. ElseIf N2 = 3200 Then : X1 = "BM" : X2 = "BN" : End If
  169. End Sub
  170. Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  171. 分行()
  172. xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 12).Select()
  173. With myExcel.Selection.Font : .Name = "新細明體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  174. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  175. xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 1).Select()
  176. With myExcel.Selection.Font : .Name = "新細明體" : .Size = 20 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  177. .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  178. myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  179. myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
  180. With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
  181. myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  182. xlSheet.Range(X2 & N1 + 3 & ":" & X2 & N1 + 12).Select()
  183. With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  184. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  185. xlSheet.Range(X2 & N1 + 3 & ":" & X2 & N1 + 12).Select()
  186. With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
  187. .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
  188. xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 2).Select()
  189. With myExcel.Selection.Font : .Name = "微軟正黑體" : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
  190. .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
  191. xlSheet.Rows(N1 + 1 & ":" & N1 + 1).Select : myExcel.Selection.RowHeight = 60
  192. xlSheet.Rows(N1 + 2 & ":" & N1 + 2).Select : myExcel.Selection.RowHeight = 20
  193. xlSheet.Rows(N1 + 3 & ":" & N1 + 3).Select : myExcel.Selection.RowHeight = 20
  194. xlSheet.Rows(N1 + 4 & ":" & N1 + 4).Select : myExcel.Selection.RowHeight = 25
  195. xlSheet.Rows(N1 + 5 & ":" & N1 + 5).Select : myExcel.Selection.RowHeight = 20
  196. xlSheet.Rows(N1 + 6 & ":" & N1 + 6).Select : myExcel.Selection.RowHeight = 20
  197. xlSheet.Rows(N1 + 7 & ":" & N1 + 7).Select : myExcel.Selection.RowHeight = 20
  198. xlSheet.Rows(N1 + 8 & ":" & N1 + 8).Select : myExcel.Selection.RowHeight = 35
  199. xlSheet.Rows(N1 + 9 & ":" & N1 + 9).Select : myExcel.Selection.RowHeight = 20
  200. xlSheet.Rows(N1 + 10 & ":" & N1 + 10).Select : myExcel.Selection.RowHeight = 20
  201. xlSheet.Rows(N1 + 11 & ":" & N1 + 11).Select : myExcel.Selection.RowHeight = 20
  202. xlSheet.Rows(N1 + 12 & ":" & N1 + 12).Select : myExcel.Selection.RowHeight = 20
  203. xlSheet.Cells.Select() : myExcel.Selection.Font.Bold = True
  204. xlSheet.Columns(X1 & ":" & X1).Select : myExcel.Selection.ColumnWidth = 10
  205. xlSheet.Columns(X2 & ":" & X2).Select : myExcel.Selection.ColumnWidth = 20
  206. End Sub
  207. Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
  208. myExcel.Application.PrintCommunication = False
  209. With myExcel.ActiveSheet.PageSetup
  210. .PrintTitleRows = ""
  211. .PrintTitleColumns = ""
  212. End With
  213. myExcel.Application.PrintCommunication = True
  214. myExcel.Application.PrintCommunication = False
  215. With myExcel.ActiveSheet.PageSetup
  216. .LeftHeader = ""
  217. .CenterHeader = ""
  218. .RightHeader = ""
  219. .LeftFooter = ""
  220. .CenterFooter = ""
  221. .RightFooter = ""
  222. .LeftMargin = myExcel.Application.InchesToPoints(0)
  223. .RightMargin = myExcel.Application.InchesToPoints(0)
  224. .TopMargin = myExcel.Application.InchesToPoints(0.0393700787401575)
  225. .BottomMargin = myExcel.Application.InchesToPoints(0.0393700787401575)
  226. .HeaderMargin = myExcel.Application.InchesToPoints(0)
  227. .FooterMargin = myExcel.Application.InchesToPoints(0)
  228. .PrintHeadings = False
  229. .PrintGridlines = False
  230. .CenterHorizontally = True
  231. .CenterVertically = True
  232. .Draft = False
  233. .FirstPageNumber = xlAutomatic
  234. .BlackAndWhite = False
  235. .Zoom = 55
  236. .OddAndEvenPagesHeaderFooter = False
  237. .DifferentFirstPageHeaderFooter = False
  238. .ScaleWithDocHeaderFooter = True
  239. .AlignMarginsHeaderFooter = True
  240. .EvenPage.LeftHeader.Text = ""
  241. .EvenPage.CenterHeader.Text = ""
  242. .EvenPage.RightHeader.Text = ""
  243. .EvenPage.LeftFooter.Text = ""
  244. .EvenPage.CenterFooter.Text = ""
  245. .EvenPage.RightFooter.Text = ""
  246. .FirstPage.LeftHeader.Text = ""
  247. .FirstPage.CenterHeader.Text = ""
  248. .FirstPage.RightHeader.Text = ""
  249. .FirstPage.LeftFooter.Text = ""
  250. .FirstPage.CenterFooter.Text = ""
  251. .FirstPage.RightFooter.Text = ""
  252. End With
  253. myExcel.Application.PrintCommunication = True
  254. End Sub
  255. Private Sub 主表單_dgv_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 主表單_dgv.MouseUp
  256. If 主表單_dgv.SelectedCells.Count = 1 Then
  257. 已超出 = False
  258. End If
  259. If 主表單_dgv.SelectedCells.Count > 0 Then
  260. '設定滑鼠點擊DGV時候的範圍,超出範圍時有可能不是數字所以不計算
  261. If 主表單_dgv.SelectedCells(0).ColumnIndex = 7 Then
  262. If 已超出 = False Then
  263. Dim x As Double = 0
  264. For i As Integer = 0 To 主表單_dgv.SelectedCells.Count - 1
  265. '主表單_dgv.SelectedCells.Item(i).ColumnIndex + 8 是因為該DGV顯示項與計算像剛好差8格,使用時要注意可直接計算的不需要加數字。
  266. x += Val(主表單_dgv.Rows(主表單_dgv.SelectedCells.Item(i).RowIndex).Cells(主表單_dgv.SelectedCells.Item(i).ColumnIndex).Value)
  267. Next i
  268. '將計算好的資料放置到指定的控件中
  269. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(x, "#,##0.0")
  270. Else
  271. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0")
  272. End If
  273. Else
  274. 已超出 = True
  275. WINPROFIT_ERP_SYS.合計_TSSL.Text = "合計 : " & Strings.Format(0, "#,##0.0")
  276. End If
  277. End If
  278. End Sub
  279. End Class