Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
Imports Microsoft.Office.Interop.Excel.Constants
Imports Microsoft.Office.Interop.Excel.XlBordersIndex
Imports Microsoft.Office.Interop.Excel.XlLineStyle
Imports Microsoft.Office.Interop.Excel.XlBorderWeight
Imports Microsoft.Office.Interop.Excel.XlThemeFont
Imports Microsoft.Office.Interop.Excel.XlThemeColor
Imports Microsoft.Office.Interop.Excel.XlWindowState
Imports Microsoft.Office.Interop.Excel.XlPageOrientation
Imports Microsoft.Office.Interop.Excel
Public Class 排班資料
    Dim 星期 As String : Dim 天數, 總時數, 列高, 列高1, 欄寬1, 欄寬2 As Integer
    Dim 首次開啟 As Boolean : Dim 位置, 位置1, 位置2, 位置3, 位置4, 位置5, 位置6 As Integer
    Dim xlApp As Application : Dim xlBook As Workbook : Dim xlSheet As Worksheet
    Private Sub 年份_下拉表單資料載入()
        SQL_考勤明細表_年份_下拉()
        年份_cb.Items.Clear()
        While (dr.Read()) : 年份_cb.Items.Add(dr("年份")) : End While
        conn.Close()
    End Sub
    Private Sub 讀取排班()
        Dim ds43 As New DataSet : 人員彙總_dgv.DataSource = Nothing : ds43.Clear()
        人員彙總_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        人員彙總_dgv.ColumnHeadersHeight = 45 : 人員彙總_dgv.AllowUserToAddRows = False : 人員彙總_dgv.RowTemplate.Height = 30
        SQL_排班系統_人員排班()
        da.Fill(ds43) : 人員彙總_dgv.DataSource = ds43.Tables(0) : conn.Close()
        人員彙總_dgv.Columns(0).ReadOnly = True : 人員彙總_dgv.Columns(1).ReadOnly = True : 人員彙總_dgv.Columns(2).ReadOnly = True
        人員彙總_dgv.Columns(3).ReadOnly = True : 人員彙總_dgv.Columns(4).ReadOnly = True : 人員彙總_dgv.Columns(5).ReadOnly = True
        人員彙總_dgv.Columns(1).FillWeight = 80 : 人員彙總_dgv.Columns(5).FillWeight = 80 : 人員彙總_dgv.Columns("後段").Visible = False

        人員彙總_dgv.Columns(1).DefaultCellStyle.Format = "#,##0" : 人員彙總_dgv.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        人員彙總_dgv.Columns(2).DefaultCellStyle.Format = "#,##0" : 人員彙總_dgv.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        人員彙總_dgv.Columns(3).DefaultCellStyle.Format = "#,##0.0" : 人員彙總_dgv.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        人員彙總_dgv.Columns(4).DefaultCellStyle.Format = "#,##0.0" : 人員彙總_dgv.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        人員彙總_dgv.Columns(5).DefaultCellStyle.Format = "#,##0" : 人員彙總_dgv.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        For i As Integer = 0 To 人員彙總_dgv.Rows.Count - 1
            Dim SS As Double = CInt(人員彙總_dgv.Rows(i).Cells("天數").Value.ToString) * 4
            人員彙總_dgv.Rows(i).Cells("後段").Value = SS - CDbl(人員彙總_dgv.Rows(i).Cells("後段").Value.ToString)
            人員彙總_dgv.Rows(i).Cells("已排班時數").Value = 人員彙總_dgv.Rows(i).Cells("已排班時數").Value - 人員彙總_dgv.Rows(i).Cells("後段").Value
            人員彙總_dgv.Rows(i).Cells("未排班時數").Value = 人員彙總_dgv.Rows(i).Cells("未排班時數").Value + 人員彙總_dgv.Rows(i).Cells("後段").Value
        Next
    End Sub
    Private Sub 讀取日期()
        Dim ds As New DataSet : 日期_dgv.DataSource = Nothing : ds.Clear()
        日期_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        日期_dgv.ColumnHeadersHeight = 25 : 日期_dgv.AllowUserToAddRows = False
        SQL_排班系統_月份()
        da.Fill(ds) : 日期_dgv.DataSource = ds.Tables(0) : conn.Close()
    End Sub
    Private Sub 讀取班別1()
        Dim ds1 As New DataSet : DataGridView1.DataSource = Nothing : ds1.Clear()
        DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView1.ColumnHeadersHeight = 列高1 : DataGridView1.AllowUserToAddRows = False : DataGridView1.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds1) : DataGridView1.DataSource = ds1.Tables(0) : conn.Close()
        DataGridView1.Columns(0).FillWeight = 欄寬1 : DataGridView1.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView1.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView1(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView1(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView1.RowHeadersVisible, DataGridView1.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView1.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別2()
        Dim ds2 As New DataSet : DataGridView2.DataSource = Nothing : ds2.Clear()
        DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView2.ColumnHeadersHeight = 列高1 : DataGridView2.AllowUserToAddRows = False : DataGridView2.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds2) : DataGridView2.DataSource = ds2.Tables(0) : conn.Close()
        DataGridView2.Columns(0).FillWeight = 欄寬1 : DataGridView2.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView2_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView2.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView2.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView2(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView2(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView2.RowHeadersVisible, DataGridView2.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView2.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView2.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別3()
        Dim ds3 As New DataSet : DataGridView3.DataSource = Nothing : ds3.Clear()
        DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView3.ColumnHeadersHeight = 列高1 : DataGridView3.AllowUserToAddRows = False : DataGridView3.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds3) : DataGridView3.DataSource = ds3.Tables(0) : conn.Close()
        DataGridView3.Columns(0).FillWeight = 欄寬1 : DataGridView3.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView3.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView3.Rows.Count - 1 Then : Exit Sub : Else
                PA = Strings.Mid(DataGridView3(0, e.RowIndex).Value.ToString, 4, 1)
                If Strings.Mid(DataGridView3(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView3(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView3.RowHeadersVisible, DataGridView3.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView3.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView3.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別4()
        Dim ds4 As New DataSet : DataGridView4.DataSource = Nothing : ds4.Clear()
        DataGridView4.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView4.ColumnHeadersHeight = 列高1 : DataGridView4.AllowUserToAddRows = False : DataGridView4.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds4) : DataGridView4.DataSource = ds4.Tables(0) : conn.Close()
        DataGridView4.Columns(0).FillWeight = 欄寬1 : DataGridView4.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView4_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView4.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView4.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView4(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView4(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView4.RowHeadersVisible, DataGridView4.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView4.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView4.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別5()
        Dim ds5 As New DataSet : DataGridView5.DataSource = Nothing : ds5.Clear()
        DataGridView5.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView5.ColumnHeadersHeight = 列高1 : DataGridView5.AllowUserToAddRows = False : DataGridView5.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds5) : DataGridView5.DataSource = ds5.Tables(0) : conn.Close()
        DataGridView5.Columns(0).FillWeight = 欄寬1 : DataGridView5.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView5_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView5.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView5.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView5(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView5(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView5.RowHeadersVisible, DataGridView5.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView5.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView5.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別6()
        Dim ds6 As New DataSet : DataGridView6.DataSource = Nothing : ds6.Clear()
        DataGridView6.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView6.ColumnHeadersHeight = 列高1 : DataGridView6.AllowUserToAddRows = False : DataGridView6.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds6) : DataGridView6.DataSource = ds6.Tables(0) : conn.Close()
        DataGridView6.Columns(0).FillWeight = 欄寬1 : DataGridView6.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView6_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView6.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView6.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView6(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView6(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView6.RowHeadersVisible, DataGridView6.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView6.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView6.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別7()
        Dim ds7 As New DataSet : DataGridView7.DataSource = Nothing : ds7.Clear()
        DataGridView7.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView7.ColumnHeadersHeight = 列高1 : DataGridView7.AllowUserToAddRows = False : DataGridView7.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds7) : DataGridView7.DataSource = ds7.Tables(0) : conn.Close()
        DataGridView7.Columns(0).FillWeight = 欄寬1 : DataGridView7.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView7_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView7.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView7.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView7(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView7(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView7.RowHeadersVisible, DataGridView7.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView7.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView7.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別8()
        Dim ds8 As New DataSet : DataGridView8.DataSource = Nothing : ds8.Clear()
        DataGridView8.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView8.ColumnHeadersHeight = 列高1 : DataGridView8.AllowUserToAddRows = False : DataGridView8.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds8) : DataGridView8.DataSource = ds8.Tables(0) : conn.Close()
        DataGridView8.Columns(0).FillWeight = 欄寬1 : DataGridView8.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView8_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView8.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView8.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView8(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView8(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView8.RowHeadersVisible, DataGridView8.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView8.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView8.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別9()
        Dim ds9 As New DataSet : DataGridView9.DataSource = Nothing : ds9.Clear()
        DataGridView9.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView9.ColumnHeadersHeight = 列高1 : DataGridView9.AllowUserToAddRows = False : DataGridView9.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds9) : DataGridView9.DataSource = ds9.Tables(0) : conn.Close()
        DataGridView9.Columns(0).FillWeight = 欄寬1 : DataGridView9.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView9_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView9.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView9.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView9(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView9(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView9.RowHeadersVisible, DataGridView9.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView9.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView9.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別10()
        Dim ds10 As New DataSet : DataGridView10.DataSource = Nothing : ds10.Clear()
        DataGridView10.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView10.ColumnHeadersHeight = 列高1 : DataGridView10.AllowUserToAddRows = False : DataGridView10.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds10) : DataGridView10.DataSource = ds10.Tables(0) : conn.Close()
        DataGridView10.Columns(0).FillWeight = 欄寬1 : DataGridView10.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView10_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView10.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView10.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView10(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView10(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView10.RowHeadersVisible, DataGridView10.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView10.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView10.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別11()
        Dim ds11 As New DataSet : DataGridView11.DataSource = Nothing : ds11.Clear()
        DataGridView11.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView11.ColumnHeadersHeight = 列高1 : DataGridView11.AllowUserToAddRows = False : DataGridView11.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds11) : DataGridView11.DataSource = ds11.Tables(0) : conn.Close()
        DataGridView11.Columns(0).FillWeight = 欄寬1 : DataGridView11.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView11_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView11.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView11.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView11(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView11(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView11.RowHeadersVisible, DataGridView11.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView11.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView11.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別12()
        Dim ds12 As New DataSet : DataGridView12.DataSource = Nothing : ds12.Clear()
        DataGridView12.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView12.ColumnHeadersHeight = 列高1 : DataGridView12.AllowUserToAddRows = False : DataGridView12.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds12) : DataGridView12.DataSource = ds12.Tables(0) : conn.Close()
        DataGridView12.Columns(0).FillWeight = 欄寬1 : DataGridView12.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView12_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView12.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView12.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView12(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView12(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView12.RowHeadersVisible, DataGridView12.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView12.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView12.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別13()
        Dim ds13 As New DataSet : DataGridView13.DataSource = Nothing : ds13.Clear()
        DataGridView13.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView13.ColumnHeadersHeight = 列高1 : DataGridView13.AllowUserToAddRows = False : DataGridView13.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds13) : DataGridView13.DataSource = ds13.Tables(0) : conn.Close()
        DataGridView13.Columns(0).FillWeight = 欄寬1 : DataGridView13.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView13_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView13.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView13.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView13(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView13(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView13.RowHeadersVisible, DataGridView13.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView13.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView13.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別14()
        Dim ds14 As New DataSet : DataGridView14.DataSource = Nothing : ds14.Clear()
        DataGridView14.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView14.ColumnHeadersHeight = 列高1 : DataGridView14.AllowUserToAddRows = False : DataGridView14.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds14) : DataGridView14.DataSource = ds14.Tables(0) : conn.Close()
        DataGridView14.Columns(0).FillWeight = 欄寬1 : DataGridView14.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView14_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView14.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView14.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView14(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView14(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView14.RowHeadersVisible, DataGridView14.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView14.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView14.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別15()
        Dim ds15 As New DataSet : DataGridView15.DataSource = Nothing : ds15.Clear()
        DataGridView15.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView15.ColumnHeadersHeight = 列高1 : DataGridView15.AllowUserToAddRows = False : DataGridView15.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds15) : DataGridView15.DataSource = ds15.Tables(0) : conn.Close()
        DataGridView15.Columns(0).FillWeight = 欄寬1 : DataGridView15.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView15_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView15.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView15.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView15(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView15(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView15.RowHeadersVisible, DataGridView15.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView15.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView15.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別16()
        Dim ds16 As New DataSet : DataGridView16.DataSource = Nothing : ds16.Clear()
        DataGridView16.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView16.ColumnHeadersHeight = 列高1 : DataGridView16.AllowUserToAddRows = False : DataGridView16.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds16) : DataGridView16.DataSource = ds16.Tables(0) : conn.Close()
        DataGridView16.Columns(0).FillWeight = 欄寬1 : DataGridView16.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView16_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView16.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView16.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView16(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView16(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView16.RowHeadersVisible, DataGridView16.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView16.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView16.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別17()
        Dim ds17 As New DataSet : DataGridView17.DataSource = Nothing : ds17.Clear()
        DataGridView17.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView17.ColumnHeadersHeight = 列高1 : DataGridView17.AllowUserToAddRows = False : DataGridView17.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds17) : DataGridView17.DataSource = ds17.Tables(0) : conn.Close()
        DataGridView17.Columns(0).FillWeight = 欄寬1 : DataGridView17.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView17_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView17.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView17.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView17(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView17(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView17.RowHeadersVisible, DataGridView17.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView17.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView17.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別18()
        Dim ds18 As New DataSet : DataGridView18.DataSource = Nothing : ds18.Clear()
        DataGridView18.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView18.ColumnHeadersHeight = 列高1 : DataGridView18.AllowUserToAddRows = False : DataGridView18.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds18) : DataGridView18.DataSource = ds18.Tables(0) : conn.Close()
        DataGridView18.Columns(0).FillWeight = 欄寬1 : DataGridView18.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView18_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView18.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView18.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView18(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView18(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView18.RowHeadersVisible, DataGridView18.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView18.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView18.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別19()
        Dim ds19 As New DataSet : DataGridView19.DataSource = Nothing : ds19.Clear()
        DataGridView19.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView19.ColumnHeadersHeight = 列高1 : DataGridView19.AllowUserToAddRows = False : DataGridView19.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds19) : DataGridView19.DataSource = ds19.Tables(0) : conn.Close()
        DataGridView19.Columns(0).FillWeight = 欄寬1 : DataGridView19.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView19_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView19.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView19.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView19(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView19(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView19.RowHeadersVisible, DataGridView19.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView19.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView19.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別20()
        Dim ds20 As New DataSet : DataGridView20.DataSource = Nothing : ds20.Clear()
        DataGridView20.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView20.ColumnHeadersHeight = 列高1 : DataGridView20.AllowUserToAddRows = False : DataGridView20.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds20) : DataGridView20.DataSource = ds20.Tables(0) : conn.Close()
        DataGridView20.Columns(0).FillWeight = 欄寬1 : DataGridView20.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView20_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView20.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView20.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView20(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView20(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView20.RowHeadersVisible, DataGridView20.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView20.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView20.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別21()
        Dim ds21 As New DataSet : DataGridView21.DataSource = Nothing : ds21.Clear()
        DataGridView21.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView21.ColumnHeadersHeight = 列高1 : DataGridView21.AllowUserToAddRows = False : DataGridView21.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds21) : DataGridView21.DataSource = ds21.Tables(0) : conn.Close()
        DataGridView21.Columns(0).FillWeight = 欄寬1 : DataGridView21.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView21_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView21.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView21.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView21(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView21(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView21.RowHeadersVisible, DataGridView21.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView21.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView21.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別22()
        Dim ds22 As New DataSet : DataGridView22.DataSource = Nothing : ds22.Clear()
        DataGridView22.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView22.ColumnHeadersHeight = 列高1 : DataGridView22.AllowUserToAddRows = False : DataGridView22.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds22) : DataGridView22.DataSource = ds22.Tables(0) : conn.Close()
        DataGridView22.Columns(0).FillWeight = 欄寬1 : DataGridView22.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView22_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView22.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView22.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView22(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView22(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView22.RowHeadersVisible, DataGridView22.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView22.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView22.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別23()
        Dim ds23 As New DataSet : DataGridView23.DataSource = Nothing : ds23.Clear()
        DataGridView23.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView23.ColumnHeadersHeight = 列高1 : DataGridView23.AllowUserToAddRows = False : DataGridView23.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds23) : DataGridView23.DataSource = ds23.Tables(0) : conn.Close()
        DataGridView23.Columns(0).FillWeight = 欄寬1 : DataGridView23.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView23_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView23.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView23.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView23(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView23(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView23.RowHeadersVisible, DataGridView23.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView23.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView23.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別24()
        Dim ds24 As New DataSet : DataGridView24.DataSource = Nothing : ds24.Clear()
        DataGridView24.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView24.ColumnHeadersHeight = 列高1 : DataGridView24.AllowUserToAddRows = False : DataGridView24.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds24) : DataGridView24.DataSource = ds24.Tables(0) : conn.Close()
        DataGridView24.Columns(0).FillWeight = 欄寬1 : DataGridView24.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView24_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView24.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView24.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView24(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView24(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView24.RowHeadersVisible, DataGridView24.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView24.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView24.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別25()
        Dim ds25 As New DataSet : DataGridView25.DataSource = Nothing : ds25.Clear()
        DataGridView25.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView25.ColumnHeadersHeight = 列高1 : DataGridView25.AllowUserToAddRows = False : DataGridView25.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds25) : DataGridView25.DataSource = ds25.Tables(0) : conn.Close()
        DataGridView25.Columns(0).FillWeight = 欄寬1 : DataGridView25.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView25_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView25.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView25.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView25(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView25(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView25.RowHeadersVisible, DataGridView25.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView25.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView25.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別26()
        Dim ds26 As New DataSet : DataGridView26.DataSource = Nothing : ds26.Clear()
        DataGridView26.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView26.ColumnHeadersHeight = 列高1 : DataGridView26.AllowUserToAddRows = False : DataGridView26.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds26) : DataGridView26.DataSource = ds26.Tables(0) : conn.Close()
        DataGridView26.Columns(0).FillWeight = 欄寬1 : DataGridView26.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView26_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView26.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView26.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView26(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView26(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView26.RowHeadersVisible, DataGridView26.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView26.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView26.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別27()
        Dim ds27 As New DataSet : DataGridView27.DataSource = Nothing : ds27.Clear()
        DataGridView27.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView27.ColumnHeadersHeight = 列高1 : DataGridView27.AllowUserToAddRows = False : DataGridView27.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds27) : DataGridView27.DataSource = ds27.Tables(0) : conn.Close()
        DataGridView27.Columns(0).FillWeight = 欄寬1 : DataGridView27.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView27_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView27.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView27.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView27(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView27(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView27.RowHeadersVisible, DataGridView27.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView27.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView27.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別28()
        Dim ds28 As New DataSet : DataGridView28.DataSource = Nothing : ds28.Clear()
        DataGridView28.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView28.ColumnHeadersHeight = 列高1 : DataGridView28.AllowUserToAddRows = False : DataGridView28.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds28) : DataGridView28.DataSource = ds28.Tables(0) : conn.Close()
        DataGridView28.Columns(0).FillWeight = 欄寬1 : DataGridView28.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView28_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView28.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView28.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView28(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView28(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView28.RowHeadersVisible, DataGridView28.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView28.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView28.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別29()
        Dim ds29 As New DataSet : DataGridView29.DataSource = Nothing : ds29.Clear()
        DataGridView29.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView29.ColumnHeadersHeight = 列高1 : DataGridView29.AllowUserToAddRows = False : DataGridView29.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds29) : DataGridView29.DataSource = ds29.Tables(0) : conn.Close()
        DataGridView29.Columns(0).FillWeight = 欄寬1 : DataGridView29.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView29_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView29.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView29.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView29(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView29(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView29.RowHeadersVisible, DataGridView29.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView29.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView29.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別30()
        Dim ds30 As New DataSet : DataGridView30.DataSource = Nothing : ds30.Clear()
        DataGridView30.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView30.ColumnHeadersHeight = 列高1 : DataGridView30.AllowUserToAddRows = False : DataGridView30.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds30) : DataGridView30.DataSource = ds30.Tables(0) : conn.Close()
        DataGridView30.Columns(0).FillWeight = 欄寬1 : DataGridView30.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView30_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView30.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView30.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView30(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView30(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView30.RowHeadersVisible, DataGridView30.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView30.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView30.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別31()
        Dim ds31 As New DataSet : DataGridView31.DataSource = Nothing : ds31.Clear()
        DataGridView31.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView31.ColumnHeadersHeight = 列高1 : DataGridView31.AllowUserToAddRows = False : DataGridView31.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds31) : DataGridView31.DataSource = ds31.Tables(0) : conn.Close()
        DataGridView31.Columns(0).FillWeight = 欄寬1 : DataGridView31.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView31_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView31.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView31.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView31(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView31(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView31.RowHeadersVisible, DataGridView31.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView31.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView31.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別32()
        Dim ds32 As New DataSet : DataGridView32.DataSource = Nothing : ds32.Clear()
        DataGridView32.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView32.ColumnHeadersHeight = 列高1 : DataGridView32.AllowUserToAddRows = False : DataGridView32.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds32) : DataGridView32.DataSource = ds32.Tables(0) : conn.Close()
        DataGridView32.Columns(0).FillWeight = 欄寬1 : DataGridView32.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView32_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView32.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView32.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView32(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView32(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView32.RowHeadersVisible, DataGridView32.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView32.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView32.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別33()
        Dim ds33 As New DataSet : DataGridView33.DataSource = Nothing : ds33.Clear()
        DataGridView33.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView33.ColumnHeadersHeight = 列高1 : DataGridView33.AllowUserToAddRows = False : DataGridView33.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds33) : DataGridView33.DataSource = ds33.Tables(0) : conn.Close()
        DataGridView33.Columns(0).FillWeight = 欄寬1 : DataGridView33.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView33_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView33.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView33.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView33(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView33(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView33.RowHeadersVisible, DataGridView33.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView33.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView33.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別34()
        Dim ds34 As New DataSet : DataGridView34.DataSource = Nothing : ds34.Clear()
        DataGridView34.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView34.ColumnHeadersHeight = 列高1 : DataGridView34.AllowUserToAddRows = False : DataGridView34.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds34) : DataGridView34.DataSource = ds34.Tables(0) : conn.Close()
        DataGridView34.Columns(0).FillWeight = 欄寬1 : DataGridView34.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView34_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView34.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView34.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView34(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView34(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView34.RowHeadersVisible, DataGridView34.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView34.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView34.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別35()
        Dim ds35 As New DataSet : DataGridView35.DataSource = Nothing : ds35.Clear()
        DataGridView35.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView35.ColumnHeadersHeight = 列高1 : DataGridView35.AllowUserToAddRows = False : DataGridView35.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds35) : DataGridView35.DataSource = ds35.Tables(0) : conn.Close()
        DataGridView35.Columns(0).FillWeight = 欄寬1 : DataGridView35.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView35_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView35.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView35.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView35(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView35(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView35.RowHeadersVisible, DataGridView35.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView35.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView35.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別36()
        Dim ds36 As New DataSet : DataGridView36.DataSource = Nothing : ds36.Clear()
        DataGridView36.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView36.ColumnHeadersHeight = 列高1 : DataGridView36.AllowUserToAddRows = False : DataGridView36.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds36) : DataGridView36.DataSource = ds36.Tables(0) : conn.Close()
        DataGridView36.Columns(0).FillWeight = 欄寬1 : DataGridView36.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView36_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView36.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView36.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView36(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView36(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView36.RowHeadersVisible, DataGridView36.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView36.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView36.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別37()
        Dim ds37 As New DataSet : DataGridView37.DataSource = Nothing : ds37.Clear()
        DataGridView37.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView37.ColumnHeadersHeight = 列高1 : DataGridView37.AllowUserToAddRows = False : DataGridView37.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds37) : DataGridView37.DataSource = ds37.Tables(0) : conn.Close()
        DataGridView37.Columns(0).FillWeight = 欄寬1 : DataGridView37.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView37_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView37.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView37.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView37(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView37(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView37.RowHeadersVisible, DataGridView37.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView37.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView37.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別38()
        Dim ds38 As New DataSet : DataGridView38.DataSource = Nothing : ds38.Clear()
        DataGridView38.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView38.ColumnHeadersHeight = 列高1 : DataGridView38.AllowUserToAddRows = False : DataGridView38.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds38) : DataGridView38.DataSource = ds38.Tables(0) : conn.Close()
        DataGridView38.Columns(0).FillWeight = 欄寬1 : DataGridView38.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView38_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView38.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView38.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView38(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView38(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView38.RowHeadersVisible, DataGridView38.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView38.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView38.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別39()
        Dim ds39 As New DataSet : DataGridView39.DataSource = Nothing : ds39.Clear()
        DataGridView39.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView39.ColumnHeadersHeight = 列高1 : DataGridView39.AllowUserToAddRows = False : DataGridView39.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds39) : DataGridView39.DataSource = ds39.Tables(0) : conn.Close()
        DataGridView39.Columns(0).FillWeight = 欄寬1 : DataGridView39.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView39_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView39.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView39.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView39(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView39(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView39.RowHeadersVisible, DataGridView39.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView39.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView39.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別40()
        Dim ds40 As New DataSet : DataGridView40.DataSource = Nothing : ds40.Clear()
        DataGridView40.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView40.ColumnHeadersHeight = 列高1 : DataGridView40.AllowUserToAddRows = False : DataGridView40.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds40) : DataGridView40.DataSource = ds40.Tables(0) : conn.Close()
        DataGridView40.Columns(0).FillWeight = 欄寬1 : DataGridView40.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView40_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView40.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView40.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView40(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView40(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView40.RowHeadersVisible, DataGridView40.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView40.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView40.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別41()
        Dim ds41 As New DataSet : DataGridView41.DataSource = Nothing : ds41.Clear()
        DataGridView41.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView41.ColumnHeadersHeight = 列高1 : DataGridView41.AllowUserToAddRows = False : DataGridView41.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds41) : DataGridView41.DataSource = ds41.Tables(0) : conn.Close()
        DataGridView41.Columns(0).FillWeight = 欄寬1 : DataGridView41.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView41_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView41.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView41.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView41(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView41(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView41.RowHeadersVisible, DataGridView41.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView41.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView41.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 讀取班別42()
        Dim ds42 As New DataSet : DataGridView42.DataSource = Nothing : ds42.Clear()
        DataGridView42.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView42.ColumnHeadersHeight = 列高1 : DataGridView42.AllowUserToAddRows = False : DataGridView42.RowTemplate.Height = 列高
        SQL_排班系統_當天排班()
        da.Fill(ds42) : DataGridView42.DataSource = ds42.Tables(0) : conn.Close()
        DataGridView42.Columns(0).FillWeight = 欄寬1 : DataGridView42.Columns(1).FillWeight = 欄寬2
    End Sub
    Private Sub DataGridView42_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView42.RowPostPaint
        If 醫生_ch.Checked = True Then
            Dim linePen As New Pen(Color.Red, 2)
            If e.RowIndex = DataGridView42.Rows.Count - 1 Then : Exit Sub : Else
                If Strings.Mid(DataGridView42(0, e.RowIndex).Value.ToString, 4, 1) <> Strings.Mid(DataGridView42(0, e.RowIndex + 1).Value.ToString, 4, 1) Then
                    Dim startX As Integer = IIf(DataGridView42.RowHeadersVisible, DataGridView42.RowHeadersWidth, 0) : Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                    Dim endX As Integer = startX + DataGridView42.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView42.HorizontalScrollingOffset
                    e.Graphics.DrawLine(linePen, startX, startY, endX, startY) : Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub 日曆變動()
        If 日期_dgv.Rows.Count > 0 Then
            總時數 = 0
            For no As Integer = 1 To 42
                Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = True
                Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label) : Labels.Text = "XX"
                Dim DataGridViewS As DataGridView = CType(Me.Controls.Find("DataGridView" + no.ToString(), True)(0), DataGridView) : DataGridViewS.DataSource = Nothing
            Next
            Dim Q As Integer = 0
            星期 = 日期_dgv.Rows(0).Cells("星期").Value.ToString : 天數 = 日期_dgv.Rows.Count
            If 星期 = "星期日" Then
                For no As Integer = 1 To 42
                    If no > 天數 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no < 10 Then : PA = "0" & no : Else : PA = no : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 1 And no <= 天數 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期一" Then
                For no As Integer = 1 To 42
                    If no = 1 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 1 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 1
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 1 < 10 Then : PA = "0" & no - 1 : Else : PA = no - 1 : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 2 And no <= 天數 + 1 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期二" Then
                For no As Integer = 1 To 42
                    If no = 1 Or no = 2 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 2 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 2
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 2 < 10 Then : PA = "0" & no - 2 : Else : PA = no - 2 : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 3 And no <= 天數 + 2 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期三" Then
                For no As Integer = 1 To 42
                    If no = 1 Or no = 2 Or no = 3 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 3 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 3
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 3 < 10 Then : PA = "0" & no - 3 : Else : PA = no - 3 : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 4 And no <= 天數 + 3 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期四" Then
                For no As Integer = 1 To 42
                    If no = 1 Or no = 2 Or no = 3 Or no = 4 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 4 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 4
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 4 < 10 Then : PA = "0" & no - 4 : Else : PA = no - 4 : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 5 And no <= 天數 + 4 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期五" Then
                For no As Integer = 1 To 42
                    If no = 1 Or no = 2 Or no = 3 Or no = 4 Or no = 5 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 5 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 5
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 5 < 10 Then : PA = "0" & Math.Abs(no - 5) : Else : PA = Math.Abs(no - 5) : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 6 And no <= 天數 + 5 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
            If 星期 = "星期六" Then
                For no As Integer = 1 To 42
                    If no = 1 Or no = 2 Or no = 3 Or no = 4 Or no = 5 Or no = 6 Then
                        Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    If no > 天數 + 6 Then : Dim Panels As Panel = CType(Me.Controls.Find("Panel" + no.ToString(), True)(0), Panel) : Panels.Visible = False : End If
                    Dim 日期_lb As System.Windows.Forms.Label = CType(Me.Controls.Find("日期_lb" + no.ToString(), True)(0), System.Windows.Forms.Label) : 日期_lb.Text = no - 6
                    If IsNumeric(Val(日期_lb.Text)) = True Then
                        If no - 6 < 10 Then : PA = "0" & no - 6 : Else : PA = no - 6 : End If : PA = 年份_cb.Text & "/" & 月份_cb.Text & "/" & PA
                        If no = 1 Then : 讀取班別1() : ElseIf no = 2 Then : 讀取班別2() : ElseIf no = 3 Then : 讀取班別3() : ElseIf no = 4 Then : 讀取班別4()
                        ElseIf no = 5 Then : 讀取班別5() : ElseIf no = 6 Then : 讀取班別6() : ElseIf no = 7 Then : 讀取班別7() : ElseIf no = 8 Then : 讀取班別8()
                        ElseIf no = 9 Then : 讀取班別9() : ElseIf no = 10 Then : 讀取班別10() : ElseIf no = 11 Then : 讀取班別11() : ElseIf no = 12 Then : 讀取班別12()
                        ElseIf no = 13 Then : 讀取班別13() : ElseIf no = 14 Then : 讀取班別14() : ElseIf no = 15 Then : 讀取班別15() : ElseIf no = 16 Then : 讀取班別16()
                        ElseIf no = 17 Then : 讀取班別17() : ElseIf no = 18 Then : 讀取班別18() : ElseIf no = 19 Then : 讀取班別19() : ElseIf no = 20 Then : 讀取班別20()
                        ElseIf no = 21 Then : 讀取班別21() : ElseIf no = 22 Then : 讀取班別22() : ElseIf no = 23 Then : 讀取班別23() : ElseIf no = 24 Then : 讀取班別24()
                        ElseIf no = 25 Then : 讀取班別25() : ElseIf no = 26 Then : 讀取班別26() : ElseIf no = 27 Then : 讀取班別27() : ElseIf no = 28 Then : 讀取班別28()
                        ElseIf no = 29 Then : 讀取班別29() : ElseIf no = 30 Then : 讀取班別30() : ElseIf no = 31 Then : 讀取班別31() : ElseIf no = 32 Then : 讀取班別32()
                        ElseIf no = 33 Then : 讀取班別33() : ElseIf no = 34 Then : 讀取班別34() : ElseIf no = 35 Then : 讀取班別35() : ElseIf no = 36 Then : 讀取班別36()
                        ElseIf no = 37 Then : 讀取班別37() : ElseIf no = 38 Then : 讀取班別38() : ElseIf no = 39 Then : 讀取班別39() : ElseIf no = 40 Then : 讀取班別40()
                        ElseIf no = 41 Then : 讀取班別41() : ElseIf no = 42 Then : 讀取班別42() : End If
                    End If
                    If no >= 7 And no <= 天數 + 6 Then
                        Dim Labels As System.Windows.Forms.Label = CType(Me.Controls.Find("Label" + no.ToString(), True)(0), System.Windows.Forms.Label)
                        Labels.Text = 日期_dgv.Rows(Q).Cells("休假").Value.ToString
                        If 日期_dgv.Rows(Q).Cells("休假").Value.ToString <> "國定假日" And 日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期日" And
                        日期_dgv.Rows(Q).Cells("星期").Value.ToString <> "星期六" Then
                            總時數 += 8
                        End If : Q += 1
                    End If
                Next
            End If
        End If
    End Sub
    Private Sub 排班資料_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = GRAMS_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        列高 = 17 : 列高1 = 22 : 欄寬1 = 80 : 欄寬2 = 200
        年份_下拉表單資料載入() : 日期_dgv.Visible = False

        首次開啟 = False
        年份_cb.Text = Year(Today) : 月份_cb.SelectedIndex = Month(Today) - 1
        PA1 = 年份_cb.Text : PA2 = 月份_cb.Text
        首次開啟 = True

        讀取日期() : 日曆變動()
        PA = 年份_cb.Text & "/" & 月份_cb.Text
        讀取排班()
        For i As Integer = 0 To 人員彙總_dgv.Rows.Count - 1
            人員彙總_dgv.Rows(i).Cells("本月應上時數").Value = 總時數
            人員彙總_dgv.Rows(i).Cells("未排班時數").Value = 人員彙總_dgv.Rows(i).Cells("本月應上時數").Value - 人員彙總_dgv.Rows(i).Cells("已排班時數").Value
        Next
    End Sub
    Private Sub 人員彙總_dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles 人員彙總_dgv.CellClick
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 人員彙總_dgv.Rows(e.RowIndex).Cells("姓名").Value : 個人班表.Close() : 個人班表.Show() : 個人班表.BringToFront()
    End Sub
    Private Sub 月份_cb_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 月份_cb.SelectedIndexChanged
        If 首次開啟 = True Then
            PA1 = 年份_cb.Text : PA2 = 月份_cb.Text : 讀取日期() : 日曆變動()
            PA = 年份_cb.Text & "/" & 月份_cb.Text : 讀取排班()
            For i As Integer = 0 To 人員彙總_dgv.Rows.Count - 1
                人員彙總_dgv.Rows(i).Cells("本月應上時數").Value = 總時數
                人員彙總_dgv.Rows(i).Cells("未排班時數").Value = 人員彙總_dgv.Rows(i).Cells("本月應上時數").Value - 人員彙總_dgv.Rows(i).Cells("已排班時數").Value
            Next
        End If
    End Sub
    Private Sub 重新讀取_bt_Click(sender As Object, e As EventArgs) Handles 重新讀取_bt.Click
        PA1 = 年份_cb.Text : PA2 = 月份_cb.Text : 讀取日期() : 日曆變動()
        PA = 年份_cb.Text & "/" & 月份_cb.Text : 讀取排班()
        For i As Integer = 0 To 人員彙總_dgv.Rows.Count - 1
            人員彙總_dgv.Rows(i).Cells("本月應上時數").Value = 總時數
            人員彙總_dgv.Rows(i).Cells("未排班時數").Value = 人員彙總_dgv.Rows(i).Cells("本月應上時數").Value - 人員彙總_dgv.Rows(i).Cells("已排班時數").Value
        Next
    End Sub
    Private Sub 醫生_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 醫生_ch.Click
        醫生_ch.Checked = True : 職員_ch.Checked = False : 請休假_ch.Checked = False : 日曆變動()
    End Sub
    Private Sub 職員_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 職員_ch.Click
        醫生_ch.Checked = False : 職員_ch.Checked = True : 請休假_ch.Checked = False : 日曆變動()
    End Sub
    Private Sub 請休假_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 請休假_ch.Click
        醫生_ch.Checked = False : 職員_ch.Checked = False : 請休假_ch.Checked = True : 日曆變動()
    End Sub
    Private Sub B01_tb_Click(sender As Object, e As EventArgs) Handles B01_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb1.Text : 排班明細.Show()
    End Sub
    Private Sub B02_tb_Click(sender As Object, e As EventArgs) Handles B02_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb2.Text : 排班明細.Show()
    End Sub
    Private Sub B03_tb_Click(sender As Object, e As EventArgs) Handles B03_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb3.Text : 排班明細.Show()
    End Sub
    Private Sub B04_tb_Click(sender As Object, e As EventArgs) Handles B04_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb4.Text : 排班明細.Show()
    End Sub
    Private Sub B05_tb_Click(sender As Object, e As EventArgs) Handles B05_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb5.Text : 排班明細.Show()
    End Sub
    Private Sub B06_tb_Click(sender As Object, e As EventArgs) Handles B06_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb6.Text : 排班明細.Show()
    End Sub
    Private Sub B07_tb_Click(sender As Object, e As EventArgs) Handles B07_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb7.Text : 排班明細.Show()
    End Sub
    Private Sub B08_tb_Click(sender As Object, e As EventArgs) Handles B08_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb8.Text : 排班明細.Show()
    End Sub
    Private Sub B09_tb_Click(sender As Object, e As EventArgs) Handles B09_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb9.Text : 排班明細.Show()
    End Sub
    Private Sub B10_tb_Click(sender As Object, e As EventArgs) Handles B10_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb10.Text : 排班明細.Show()
    End Sub
    Private Sub B11_tb_Click(sender As Object, e As EventArgs) Handles B11_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb11.Text : 排班明細.Show()
    End Sub
    Private Sub B12_tb_Click(sender As Object, e As EventArgs) Handles B12_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb12.Text : 排班明細.Show()
    End Sub
    Private Sub B13_tb_Click(sender As Object, e As EventArgs) Handles B13_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb13.Text : 排班明細.Show()
    End Sub
    Private Sub B14_tb_Click(sender As Object, e As EventArgs) Handles B14_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb14.Text : 排班明細.Show()
    End Sub
    Private Sub B15_tb_Click(sender As Object, e As EventArgs) Handles B15_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb15.Text : 排班明細.Show()
    End Sub
    Private Sub B16_tb_Click(sender As Object, e As EventArgs) Handles B16_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb16.Text : 排班明細.Show()
    End Sub
    Private Sub B17_tb_Click(sender As Object, e As EventArgs) Handles B17_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb17.Text : 排班明細.Show()
    End Sub
    Private Sub B18_tb_Click(sender As Object, e As EventArgs) Handles B18_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb18.Text : 排班明細.Show()
    End Sub
    Private Sub B19_tb_Click(sender As Object, e As EventArgs) Handles B19_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb19.Text : 排班明細.Show()
    End Sub
    Private Sub B20_tb_Click(sender As Object, e As EventArgs) Handles B20_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb20.Text : 排班明細.Show()
    End Sub
    Private Sub B21_tb_Click(sender As Object, e As EventArgs) Handles B21_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb21.Text : 排班明細.Show()
    End Sub
    Private Sub B22_tb_Click(sender As Object, e As EventArgs) Handles B22_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb22.Text : 排班明細.Show()
    End Sub
    Private Sub B23_tb_Click(sender As Object, e As EventArgs) Handles B23_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb23.Text : 排班明細.Show()
    End Sub
    Private Sub B24_tb_Click(sender As Object, e As EventArgs) Handles B24_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb24.Text : 排班明細.Show()
    End Sub
    Private Sub B25_tb_Click(sender As Object, e As EventArgs) Handles B25_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb25.Text : 排班明細.Show()
    End Sub
    Private Sub B26_tb_Click(sender As Object, e As EventArgs) Handles B26_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb26.Text : 排班明細.Show()
    End Sub
    Private Sub B27_tb_Click(sender As Object, e As EventArgs) Handles B27_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb27.Text : 排班明細.Show()
    End Sub
    Private Sub B28_tb_Click(sender As Object, e As EventArgs) Handles B28_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb28.Text : 排班明細.Show()
    End Sub
    Private Sub B29_tb_Click(sender As Object, e As EventArgs) Handles B29_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb29.Text : 排班明細.Show()
    End Sub
    Private Sub B30_tb_Click(sender As Object, e As EventArgs) Handles B30_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb30.Text : 排班明細.Show()
    End Sub
    Private Sub B31_tb_Click(sender As Object, e As EventArgs) Handles B31_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb31.Text : 排班明細.Show()
    End Sub
    Private Sub B32_tb_Click(sender As Object, e As EventArgs) Handles B32_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb32.Text : 排班明細.Show()
    End Sub
    Private Sub B33_tb_Click(sender As Object, e As EventArgs) Handles B33_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb33.Text : 排班明細.Show()
    End Sub
    Private Sub B34_tb_Click(sender As Object, e As EventArgs) Handles B34_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb34.Text : 排班明細.Show()
    End Sub
    Private Sub B35_tb_Click(sender As Object, e As EventArgs) Handles B35_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb35.Text : 排班明細.Show()
    End Sub
    Private Sub B36_tb_Click(sender As Object, e As EventArgs) Handles B36_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb36.Text : 排班明細.Show()
    End Sub
    Private Sub B37_tb_Click(sender As Object, e As EventArgs) Handles B37_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb37.Text : 排班明細.Show()
    End Sub
    Private Sub B38_tb_Click(sender As Object, e As EventArgs) Handles B38_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb38.Text : 排班明細.Show()
    End Sub
    Private Sub B39_tb_Click(sender As Object, e As EventArgs) Handles B39_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb39.Text : 排班明細.Show()
    End Sub
    Private Sub B40_tb_Click(sender As Object, e As EventArgs) Handles B40_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb40.Text : 排班明細.Show()
    End Sub
    Private Sub B41_tb_Click(sender As Object, e As EventArgs) Handles B41_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb41.Text : 排班明細.Show()
    End Sub
    Private Sub B42_tb_Click(sender As Object, e As EventArgs) Handles B42_tb.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb42.Text : 排班明細.Show()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb1.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb2.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb3.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb4.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb5.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb6.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb7.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb8.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb9.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb10.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb11.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb12.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb13.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb14.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb15.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb16.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb17.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb18.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb19.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb20.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb21.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb22.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb23.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb24.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb25.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb26.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb27.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button28_Click(sender As Object, e As EventArgs) Handles Button28.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb28.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button29_Click(sender As Object, e As EventArgs) Handles Button29.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb29.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button30_Click(sender As Object, e As EventArgs) Handles Button30.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb30.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button31_Click(sender As Object, e As EventArgs) Handles Button31.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb31.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button32_Click(sender As Object, e As EventArgs) Handles Button32.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb32.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button33_Click(sender As Object, e As EventArgs) Handles Button33.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb33.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button34_Click(sender As Object, e As EventArgs) Handles Button34.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb34.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button35_Click(sender As Object, e As EventArgs) Handles Button35.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb35.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button36_Click(sender As Object, e As EventArgs) Handles Button36.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb36.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button37_Click(sender As Object, e As EventArgs) Handles Button37.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb37.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button38_Click(sender As Object, e As EventArgs) Handles Button38.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb38.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button39_Click(sender As Object, e As EventArgs) Handles Button39.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb39.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button40_Click(sender As Object, e As EventArgs) Handles Button40.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb40.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button41_Click(sender As Object, e As EventArgs) Handles Button41.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb41.Text : 排班明細_參考.Show()
    End Sub
    Private Sub Button42_Click(sender As Object, e As EventArgs) Handles Button42.Click
        PA = 年份_cb.Text : PA1 = 月份_cb.Text : PA2 = 日期_lb42.Text : 排班明細_參考.Show()
    End Sub
    Private Sub 列印_bt_Click(sender As Object, e As EventArgs) Handles 列印_bt.Click
        排班資料列印選擇.ShowDialog()
        xlApp = CType(CreateObject("Excel.Application"), Application)
        xlBook = xlApp.Workbooks.Add
        xlApp.DisplayAlerts = True
        xlApp.Visible = True
        xlApp.Application.WindowState = xlMaximized

        If PA = "統計" Then
            xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
            xlApp.Sheets(1).Name = "排班資料統計" : xlBook.Activate() : xlSheet.Activate()
            xlSheet.Cells(1, 1) = "黃柏翰皮膚科診所-排班資料統計" : xlSheet.Cells(2, 1) = CInt(年份_cb.Text) - 1911 & "年" & 月份_cb.Text & "月 - 全月"
            xlSheet.Cells(3, 1) = "項" : xlSheet.Cells(3, 2) = "姓名" : xlSheet.Cells(3, 3) = "天數" : xlSheet.Cells(3, 4) = "本月應上時數"
            xlSheet.Cells(3, 5) = "已排班時數" : xlSheet.Cells(3, 6) = "未排班時數" : xlSheet.Cells(3, 7) = "假日出勤"
            For i As Integer = 0 To 人員彙總_dgv.Rows.Count - 1
                xlSheet.Cells(4 + i, 1) = i + 1 : xlSheet.Cells(4 + i, 2) = 人員彙總_dgv("姓名", i).Value.ToString
                xlSheet.Cells(4 + i, 3) = 人員彙總_dgv("天數", i).Value.ToString
                xlSheet.Cells(4 + i, 4) = 人員彙總_dgv("本月應上時數", i).Value.ToString
                xlSheet.Cells(4 + i, 5) = 人員彙總_dgv("已排班時數", i).Value.ToString
                xlSheet.Cells(4 + i, 6) = 人員彙總_dgv("未排班時數", i).Value.ToString
                xlSheet.Cells(4 + i, 7) = 人員彙總_dgv("假日出勤", i).Value.ToString
            Next : 位置1 = 4 + 人員彙總_dgv.Rows.Count - 1 : AA(xlApp, xlSheet)
            xlSheet.PageSetup.PrintArea = "" : xlApp.Cells.Select() : xlSheet.Range("B1").Select() : xlApp.Application.WindowState = xlMinimized : MsgBox("排班資料統計列印完成!!")
        Else
            xlSheet = NewMethod(xlBook) : xlApp.Sheets(1).Select
            xlApp.Sheets(1).Name = "排班月曆" : xlBook.Activate() : xlSheet.Activate()
            xlSheet.Cells(1, 1) = "黃柏翰皮膚科診所-排班月曆" : xlSheet.Cells(2, 1) = CInt(年份_cb.Text) - 1911 & "年" & 月份_cb.Text & "月 - 全月"
            xlSheet.Cells(3, 1) = "星期日" : xlSheet.Cells(3, 3) = "星期一" : xlSheet.Cells(3, 5) = "星期二" : xlSheet.Cells(3, 7) = "星期三"
            xlSheet.Cells(3, 9) = "星期四" : xlSheet.Cells(3, 11) = "星期五" : xlSheet.Cells(3, 13) = "星期六" : 位置 = 0
            '-----第一排-----------
            If Label1.Text <> "XX" And CInt(日期_lb1.Text) > 0 Then : xlSheet.Cells(4, 1) = 日期_lb1.Text : xlSheet.Cells(4, 2) = Label1.Text
                For i As Integer = 0 To DataGridView1.Rows.Count - 1
                    xlSheet.Cells(5 + i, 1) = Strings.Left(DataGridView1(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 2) = DataGridView1(1, i).Value.ToString
                Next
            End If : 位置1 = DataGridView1.Rows.Count
            If Label2.Text <> "XX" And CInt(日期_lb2.Text) > 0 Then : xlSheet.Cells(4, 3) = 日期_lb2.Text : xlSheet.Cells(4, 4) = Label2.Text
                For i As Integer = 0 To DataGridView2.Rows.Count - 1
                    xlSheet.Cells(5 + i, 3) = Strings.Left(DataGridView2(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 4) = DataGridView2(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView2.Rows.Count Then : 位置1 = DataGridView2.Rows.Count : End If
            If Label3.Text <> "XX" And CInt(日期_lb3.Text) > 0 Then : xlSheet.Cells(4, 5) = 日期_lb3.Text : xlSheet.Cells(4, 6) = Label3.Text
                For i As Integer = 0 To DataGridView3.Rows.Count - 1
                    xlSheet.Cells(5 + i, 5) = Strings.Left(DataGridView3(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 6) = DataGridView3(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView3.Rows.Count Then : 位置1 = DataGridView3.Rows.Count : End If
            If Label4.Text <> "XX" And CInt(日期_lb4.Text) > 0 Then : xlSheet.Cells(4, 7) = 日期_lb4.Text : xlSheet.Cells(4, 8) = Label4.Text
                For i As Integer = 0 To DataGridView4.Rows.Count - 1
                    xlSheet.Cells(5 + i, 7) = Strings.Left(DataGridView4(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 8) = DataGridView4(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView4.Rows.Count Then : 位置1 = DataGridView4.Rows.Count : End If
            If Label5.Text <> "XX" And CInt(日期_lb5.Text) > 0 Then : xlSheet.Cells(4, 9) = 日期_lb5.Text : xlSheet.Cells(4, 10) = Label5.Text
                For i As Integer = 0 To DataGridView5.Rows.Count - 1
                    xlSheet.Cells(5 + i, 9) = Strings.Left(DataGridView5(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 10) = DataGridView5(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView5.Rows.Count Then : 位置1 = DataGridView5.Rows.Count : End If
            If Label6.Text <> "XX" And CInt(日期_lb6.Text) > 0 Then : xlSheet.Cells(4, 11) = 日期_lb6.Text : xlSheet.Cells(4, 12) = Label6.Text
                For i As Integer = 0 To DataGridView6.Rows.Count - 1
                    xlSheet.Cells(5 + i, 11) = Strings.Left(DataGridView6(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 12) = DataGridView6(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView6.Rows.Count Then : 位置1 = DataGridView6.Rows.Count : End If
            If Label7.Text <> "XX" And CInt(日期_lb7.Text) > 0 Then : xlSheet.Cells(4, 13) = 日期_lb7.Text : xlSheet.Cells(4, 14) = Label7.Text
                For i As Integer = 0 To DataGridView7.Rows.Count - 1
                    xlSheet.Cells(5 + i, 13) = Strings.Left(DataGridView7(0, i).Value.ToString, 5) : xlSheet.Cells(5 + i, 14) = DataGridView7(1, i).Value.ToString
                Next
            End If : If 位置1 < DataGridView7.Rows.Count Then : 位置1 = DataGridView7.Rows.Count : End If : 位置 += 位置1
            '-----第二排-----------
            If Label8.Text <> "XX" And CInt(日期_lb8.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 1) = 日期_lb8.Text : xlSheet.Cells(4 + 1 + 位置, 2) = Label8.Text
                For i As Integer = 0 To DataGridView8.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 1) = Strings.Left(DataGridView8(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 2) = DataGridView8(1, i).Value.ToString
                Next
            End If : 位置2 = DataGridView8.Rows.Count
            If Label9.Text <> "XX" And CInt(日期_lb9.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 3) = 日期_lb9.Text : xlSheet.Cells(4 + 1 + 位置, 4) = Label9.Text
                For i As Integer = 0 To DataGridView9.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 3) = Strings.Left(DataGridView9(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 4) = DataGridView9(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView9.Rows.Count Then : 位置2 = DataGridView9.Rows.Count : End If
            If Label10.Text <> "XX" And CInt(日期_lb10.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 5) = 日期_lb10.Text : xlSheet.Cells(4 + 1 + 位置, 6) = Label10.Text
                For i As Integer = 0 To DataGridView10.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 5) = Strings.Left(DataGridView10(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 6) = DataGridView10(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView10.Rows.Count Then : 位置2 = DataGridView10.Rows.Count : End If
            If Label11.Text <> "XX" And CInt(日期_lb11.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 7) = 日期_lb11.Text : xlSheet.Cells(4 + 1 + 位置, 8) = Label11.Text
                For i As Integer = 0 To DataGridView11.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 7) = Strings.Left(DataGridView11(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 8) = DataGridView11(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView11.Rows.Count Then : 位置2 = DataGridView11.Rows.Count : End If
            If Label12.Text <> "XX" And CInt(日期_lb12.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 9) = 日期_lb12.Text : xlSheet.Cells(4 + 1 + 位置, 10) = Label12.Text
                For i As Integer = 0 To DataGridView12.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 9) = Strings.Left(DataGridView12(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 10) = DataGridView12(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView12.Rows.Count Then : 位置2 = DataGridView12.Rows.Count : End If
            If Label13.Text <> "XX" And CInt(日期_lb13.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 11) = 日期_lb13.Text : xlSheet.Cells(4 + 1 + 位置, 12) = Label13.Text
                For i As Integer = 0 To DataGridView13.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 11) = Strings.Left(DataGridView13(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 12) = DataGridView13(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView13.Rows.Count Then : 位置2 = DataGridView13.Rows.Count : End If
            If Label14.Text <> "XX" And CInt(日期_lb14.Text) > 0 Then : xlSheet.Cells(4 + 1 + 位置, 13) = 日期_lb14.Text : xlSheet.Cells(4 + 1 + 位置, 14) = Label14.Text
                For i As Integer = 0 To DataGridView14.Rows.Count - 1
                    xlSheet.Cells(5 + 1 + 位置 + i, 13) = Strings.Left(DataGridView14(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 1 + 位置 + i, 14) = DataGridView14(1, i).Value.ToString
                Next
            End If : If 位置2 < DataGridView14.Rows.Count Then : 位置2 = DataGridView14.Rows.Count : End If : 位置 += 位置2
            '-----第三排-----------
            If Label15.Text <> "XX" And CInt(日期_lb15.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 1) = 日期_lb15.Text : xlSheet.Cells(4 + 2 + 位置, 2) = Label15.Text
                For i As Integer = 0 To DataGridView15.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 1) = Strings.Left(DataGridView15(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 2) = DataGridView15(1, i).Value.ToString
                Next
            End If : 位置3 = DataGridView15.Rows.Count
            If Label16.Text <> "XX" And CInt(日期_lb16.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 3) = 日期_lb16.Text : xlSheet.Cells(4 + 2 + 位置, 4) = Label16.Text
                For i As Integer = 0 To DataGridView16.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 3) = Strings.Left(DataGridView16(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 4) = DataGridView16(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView16.Rows.Count Then : 位置3 = DataGridView16.Rows.Count : End If
            If Label17.Text <> "XX" And CInt(日期_lb17.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 5) = 日期_lb17.Text : xlSheet.Cells(4 + 2 + 位置, 6) = Label17.Text
                For i As Integer = 0 To DataGridView17.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 5) = Strings.Left(DataGridView17(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 6) = DataGridView17(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView17.Rows.Count Then : 位置3 = DataGridView17.Rows.Count : End If
            If Label18.Text <> "XX" And CInt(日期_lb18.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 7) = 日期_lb18.Text : xlSheet.Cells(4 + 2 + 位置, 8) = Label18.Text
                For i As Integer = 0 To DataGridView18.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 7) = Strings.Left(DataGridView18(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 8) = DataGridView18(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView18.Rows.Count Then : 位置3 = DataGridView18.Rows.Count : End If
            If Label19.Text <> "XX" And CInt(日期_lb19.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 9) = 日期_lb19.Text : xlSheet.Cells(4 + 2 + 位置, 10) = Label19.Text
                For i As Integer = 0 To DataGridView19.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 9) = Strings.Left(DataGridView19(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 10) = DataGridView19(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView19.Rows.Count Then : 位置3 = DataGridView19.Rows.Count : End If
            If Label20.Text <> "XX" And CInt(日期_lb20.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 11) = 日期_lb20.Text : xlSheet.Cells(4 + 2 + 位置, 12) = Label20.Text
                For i As Integer = 0 To DataGridView20.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 11) = Strings.Left(DataGridView20(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 12) = DataGridView20(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView20.Rows.Count Then : 位置3 = DataGridView20.Rows.Count : End If
            If Label21.Text <> "XX" And CInt(日期_lb21.Text) > 0 Then : xlSheet.Cells(4 + 2 + 位置, 13) = 日期_lb21.Text : xlSheet.Cells(4 + 2 + 位置, 14) = Label21.Text
                For i As Integer = 0 To DataGridView21.Rows.Count - 1
                    xlSheet.Cells(5 + 2 + 位置 + i, 13) = Strings.Left(DataGridView21(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 2 + 位置 + i, 14) = DataGridView21(1, i).Value.ToString
                Next
            End If : If 位置3 < DataGridView21.Rows.Count Then : 位置3 = DataGridView21.Rows.Count : End If : 位置 += 位置3
            '-----第四排-----------
            If Label22.Text <> "XX" And CInt(日期_lb22.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 1) = 日期_lb22.Text : xlSheet.Cells(4 + 3 + 位置, 2) = Label22.Text
                For i As Integer = 0 To DataGridView22.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 1) = Strings.Left(DataGridView22(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 2) = DataGridView22(1, i).Value.ToString
                Next
            End If : 位置4 = DataGridView22.Rows.Count
            If Label23.Text <> "XX" And CInt(日期_lb23.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 3) = 日期_lb23.Text : xlSheet.Cells(4 + 3 + 位置, 4) = Label23.Text
                For i As Integer = 0 To DataGridView23.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 3) = Strings.Left(DataGridView23(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 4) = DataGridView23(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView23.Rows.Count Then : 位置4 = DataGridView23.Rows.Count : End If
            If Label24.Text <> "XX" And CInt(日期_lb24.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 5) = 日期_lb24.Text : xlSheet.Cells(4 + 3 + 位置, 6) = Label24.Text
                For i As Integer = 0 To DataGridView24.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 5) = Strings.Left(DataGridView24(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 6) = DataGridView24(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView24.Rows.Count Then : 位置4 = DataGridView24.Rows.Count : End If
            If Label25.Text <> "XX" And CInt(日期_lb25.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 7) = 日期_lb25.Text : xlSheet.Cells(4 + 3 + 位置, 8) = Label25.Text
                For i As Integer = 0 To DataGridView25.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 7) = Strings.Left(DataGridView25(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 8) = DataGridView25(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView25.Rows.Count Then : 位置4 = DataGridView25.Rows.Count : End If
            If Label26.Text <> "XX" And CInt(日期_lb26.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 9) = 日期_lb26.Text : xlSheet.Cells(4 + 3 + 位置, 10) = Label26.Text
                For i As Integer = 0 To DataGridView26.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 9) = Strings.Left(DataGridView26(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 10) = DataGridView26(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView26.Rows.Count Then : 位置4 = DataGridView26.Rows.Count : End If
            If Label27.Text <> "XX" And CInt(日期_lb27.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 11) = 日期_lb27.Text : xlSheet.Cells(4 + 3 + 位置, 12) = Label27.Text
                For i As Integer = 0 To DataGridView27.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 11) = Strings.Left(DataGridView27(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 12) = DataGridView27(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView27.Rows.Count Then : 位置4 = DataGridView27.Rows.Count : End If
            If Label28.Text <> "XX" And CInt(日期_lb28.Text) > 0 Then : xlSheet.Cells(4 + 3 + 位置, 13) = 日期_lb28.Text : xlSheet.Cells(4 + 3 + 位置, 14) = Label28.Text
                For i As Integer = 0 To DataGridView28.Rows.Count - 1
                    xlSheet.Cells(5 + 3 + 位置 + i, 13) = Strings.Left(DataGridView28(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 3 + 位置 + i, 14) = DataGridView28(1, i).Value.ToString
                Next
            End If : If 位置4 < DataGridView28.Rows.Count Then : 位置4 = DataGridView28.Rows.Count : End If : 位置 += 位置4
            '-----第五排-----------
            If Label29.Text <> "XX" And CInt(日期_lb29.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 1) = 日期_lb29.Text : xlSheet.Cells(4 + 4 + 位置, 2) = Label29.Text
                For i As Integer = 0 To DataGridView29.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 1) = Strings.Left(DataGridView29(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 2) = DataGridView29(1, i).Value.ToString
                Next
            End If : 位置5 = DataGridView29.Rows.Count
            If Label30.Text <> "XX" And CInt(日期_lb30.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 3) = 日期_lb30.Text : xlSheet.Cells(4 + 4 + 位置, 4) = Label30.Text
                For i As Integer = 0 To DataGridView30.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 3) = Strings.Left(DataGridView30(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 4) = DataGridView30(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView30.Rows.Count Then : 位置5 = DataGridView30.Rows.Count : End If
            If Label31.Text <> "XX" And CInt(日期_lb31.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 5) = 日期_lb31.Text : xlSheet.Cells(4 + 4 + 位置, 6) = Label31.Text
                For i As Integer = 0 To DataGridView31.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 5) = Strings.Left(DataGridView31(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 6) = DataGridView31(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView31.Rows.Count Then : 位置5 = DataGridView31.Rows.Count : End If
            If Label32.Text <> "XX" And CInt(日期_lb32.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 7) = 日期_lb32.Text : xlSheet.Cells(4 + 4 + 位置, 8) = Label32.Text
                For i As Integer = 0 To DataGridView32.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 7) = Strings.Left(DataGridView32(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 8) = DataGridView32(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView32.Rows.Count Then : 位置5 = DataGridView32.Rows.Count : End If
            If Label33.Text <> "XX" And CInt(日期_lb33.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 9) = 日期_lb33.Text : xlSheet.Cells(4 + 4 + 位置, 10) = Label33.Text
                For i As Integer = 0 To DataGridView33.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 9) = Strings.Left(DataGridView33(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 10) = DataGridView33(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView33.Rows.Count Then : 位置5 = DataGridView33.Rows.Count : End If
            If Label34.Text <> "XX" And CInt(日期_lb34.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 11) = 日期_lb34.Text : xlSheet.Cells(4 + 4 + 位置, 12) = Label34.Text
                For i As Integer = 0 To DataGridView34.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 11) = Strings.Left(DataGridView34(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 12) = DataGridView34(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView34.Rows.Count Then : 位置5 = DataGridView34.Rows.Count : End If
            If Label35.Text <> "XX" And CInt(日期_lb35.Text) > 0 Then : xlSheet.Cells(4 + 4 + 位置, 13) = 日期_lb35.Text : xlSheet.Cells(4 + 4 + 位置, 14) = Label35.Text
                For i As Integer = 0 To DataGridView35.Rows.Count - 1
                    xlSheet.Cells(5 + 4 + 位置 + i, 13) = Strings.Left(DataGridView35(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 4 + 位置 + i, 14) = DataGridView35(1, i).Value.ToString
                Next
            End If : If 位置5 < DataGridView35.Rows.Count Then : 位置5 = DataGridView35.Rows.Count : End If : 位置 += 位置5
            '-----第六排-----------
            If Label36.Text <> "XX" And CInt(日期_lb36.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 1) = 日期_lb36.Text : xlSheet.Cells(4 + 5 + 位置, 2) = Label36.Text
                For i As Integer = 0 To DataGridView36.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 1) = Strings.Left(DataGridView36(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 2) = DataGridView36(1, i).Value.ToString
                Next
            End If : 位置6 = DataGridView36.Rows.Count
            If Label37.Text <> "XX" And CInt(日期_lb37.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 3) = 日期_lb37.Text : xlSheet.Cells(4 + 5 + 位置, 4) = Label37.Text
                For i As Integer = 0 To DataGridView37.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 3) = Strings.Left(DataGridView37(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 4) = DataGridView37(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView37.Rows.Count Then : 位置6 = DataGridView37.Rows.Count : End If
            If Label38.Text <> "XX" And CInt(日期_lb38.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 5) = 日期_lb38.Text : xlSheet.Cells(4 + 5 + 位置, 6) = Label38.Text
                For i As Integer = 0 To DataGridView38.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 5) = Strings.Left(DataGridView38(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 6) = DataGridView38(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView38.Rows.Count Then : 位置6 = DataGridView38.Rows.Count : End If
            If Label39.Text <> "XX" And CInt(日期_lb39.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 7) = 日期_lb39.Text : xlSheet.Cells(4 + 5 + 位置, 8) = Label39.Text
                For i As Integer = 0 To DataGridView39.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 7) = Strings.Left(DataGridView39(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 8) = DataGridView39(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView39.Rows.Count Then : 位置6 = DataGridView39.Rows.Count : End If
            If Label40.Text <> "XX" And CInt(日期_lb40.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 9) = 日期_lb40.Text : xlSheet.Cells(4 + 5 + 位置, 10) = Label40.Text
                For i As Integer = 0 To DataGridView40.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 9) = Strings.Left(DataGridView40(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 10) = DataGridView40(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView40.Rows.Count Then : 位置6 = DataGridView40.Rows.Count : End If
            If Label41.Text <> "XX" And CInt(日期_lb41.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 11) = 日期_lb41.Text : xlSheet.Cells(4 + 5 + 位置, 12) = Label41.Text
                For i As Integer = 0 To DataGridView41.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 11) = Strings.Left(DataGridView41(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 12) = DataGridView41(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView41.Rows.Count Then : 位置6 = DataGridView41.Rows.Count : End If
            If Label42.Text <> "XX" And CInt(日期_lb42.Text) > 0 Then : xlSheet.Cells(4 + 5 + 位置, 13) = 日期_lb42.Text : xlSheet.Cells(4 + 5 + 位置, 14) = Label42.Text
                For i As Integer = 0 To DataGridView42.Rows.Count - 1
                    xlSheet.Cells(5 + 5 + 位置 + i, 13) = Strings.Left(DataGridView42(0, i).Value.ToString, 5) : xlSheet.Cells(5 + 5 + 位置 + i, 14) = DataGridView42(1, i).Value.ToString
                Next
            End If : If 位置6 < DataGridView42.Rows.Count Then : 位置6 = DataGridView42.Rows.Count : End If : 位置 += 位置6 : BB(xlApp, xlSheet)
            xlSheet.PageSetup.PrintArea = "" : xlApp.Cells.Select() : xlSheet.Range("B1").Select() : xlApp.Application.WindowState = xlMinimized : MsgBox("排班月曆列印完成!!")
        End If : PA = ""
    End Sub
    Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
        Return CType(xlBook.Worksheets.Add, Worksheet)
    End Function
    Private Sub AA(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        xlSheet.Cells.Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 11 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Columns("A:A").Select : myExcel.Selection.ColumnWidth = 4
        xlSheet.Range("A3:G" & 位置1).Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With

        xlSheet.Range("C4:G" & 位置1).Select()
        With myExcel.Selection : .HorizontalAlignment = xlRight : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
        myExcel.Selection.Style = "Comma"
        myExcel.Selection.NumberFormatLocal = "_-* #,##0.0_-;-* #,##0.0_-;_-* ""-""??_-;_-@_-"
        xlSheet.Range("C4:D" & 位置1).Select()
        myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
        xlSheet.Range("G4:G" & 位置1).Select()
        myExcel.Selection.NumberFormatLocal = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
        xlSheet.Rows("3:3").Select : myExcel.Selection.RowHeight = 35
        With myExcel.Selection : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0 : .ShrinkToFit = False
            .ReadingOrder = xlContext : .MergeCells = False : End With
        xlSheet.Columns("G:G").Select : myExcel.Selection.ColumnWidth = 6
        xlSheet.Columns("C:C").Select : myExcel.Selection.ColumnWidth = 6
        xlSheet.Columns("D:D").Select : myExcel.Selection.ColumnWidth = 7
        xlSheet.Columns("E:F").Select : myExcel.Selection.ColumnWidth = 8
        xlSheet.Range("A3:G" & 位置1).Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        With myExcel.Selection.Borders(xlInsideHorizontal) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        xlSheet.Range("A3:G3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlInsideVertical) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0 : End With
        xlSheet.Range("A2:G2").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
            .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("A1:G1").Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False
            .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("I5").Select() : myExcel.ActiveWindow.DisplayGridlines = False
    End Sub
    Private Sub BB(ByVal myExcel As Microsoft.Office.Interop.Excel.Application, ByVal xlSheet As Microsoft.Office.Interop.Excel.Worksheet)
        xlSheet.Cells.Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With
        xlSheet.Range("A:A,C:C,E:E,G:G,I:I,K:K,M:M").Select() : myExcel.Selection.ColumnWidth = 6 : myExcel.ActiveWindow.DisplayGridlines = False
        xlSheet.Rows("3:3").Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows("4:4").Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows(4 + 1 + 位置1 & ":" & 4 + 1 + 位置1).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows(4 + 2 + 位置1 + 位置2 & ":" & 4 + 2 + 位置1 + 位置2).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows(4 + 3 + 位置1 + 位置2 + 位置3 & ":" & 4 + 3 + 位置1 + 位置2 + 位置3).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows(4 + 4 + 位置1 + 位置2 + 位置3 + 位置4 & ":" & 4 + 4 + 位置1 + 位置2 + 位置3 + 位置4).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows(4 + 5 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5 & ":" & 4 + 5 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5).Select
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 12 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Range("B:B,D:D,F:F,H:H,J:J,L:L,N:N").Select() : myExcel.Selection.ColumnWidth = 24
        xlSheet.Range("A3:B3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("C3:D3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("E3:F3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("G3:H3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("I3:J3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("K3:L3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Range("M3:N3").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        xlSheet.Rows("4:4").Select : myExcel.ActiveWindow.FreezePanes = True
        Dim 第一, 第二 As String : 第一 = "" : 第二 = ""
        For i As Integer = 1 To 7
            If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
            ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
            ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
            xlSheet.Range(第一 & "4:" & 第二 & 4 + 位置1).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            xlSheet.Range(第一 & "4:" & 第二 & "4").Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Next
        For i As Integer = 1 To 7
            If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
            ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
            ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
            xlSheet.Range(第一 & 5 + 位置1 & ":" & 第二 & 5 + 位置1 + 位置2).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            xlSheet.Range(第一 & 5 + 位置1 & ":" & 第二 & 5 + 位置1).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Next
        For i As Integer = 1 To 7
            If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
            ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
            ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
            xlSheet.Range(第一 & 5 + 1 + 位置1 + 位置2 & ":" & 第二 & 5 + 1 + 位置1 + 位置2 + 位置3).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            xlSheet.Range(第一 & 5 + 1 + 位置1 + 位置2 & ":" & 第二 & 5 + 1 + 位置1 + 位置2).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Next
        For i As Integer = 1 To 7
            If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
            ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
            ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
            xlSheet.Range(第一 & 5 + 2 + 位置1 + 位置2 + 位置3 & ":" & 第二 & 5 + 2 + 位置1 + 位置2 + 位置3 + 位置4).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            xlSheet.Range(第一 & 5 + 2 + 位置1 + 位置2 + 位置3 & ":" & 第二 & 5 + 2 + 位置1 + 位置2 + 位置3).Select()
            myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
            With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
            myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Next
        If 位置5 > 0 Then
            For i As Integer = 1 To 7
                If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
                ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
                ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
                xlSheet.Range(第一 & 5 + 3 + 位置1 + 位置2 + 位置3 + 位置4 & ":" & 第二 & 5 + 3 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5).Select()
                myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
                xlSheet.Range(第一 & 5 + 3 + 位置1 + 位置2 + 位置3 + 位置4 & ":" & 第二 & 5 + 3 + 位置1 + 位置2 + 位置3 + 位置4).Select()
                myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
                With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            Next
        End If
        If 位置6 > 0 Then
            For i As Integer = 1 To 7
                If i = 1 Then : 第一 = "A" : 第二 = "B" : ElseIf i = 2 Then : 第一 = "C" : 第二 = "D" : ElseIf i = 3 Then : 第一 = "E" : 第二 = "F"
                ElseIf i = 4 Then : 第一 = "G" : 第二 = "H" : ElseIf i = 5 Then : 第一 = "I" : 第二 = "J" : ElseIf i = 6 Then : 第一 = "K" : 第二 = "L"
                ElseIf i = 7 Then : 第一 = "M" : 第二 = "N" : End If
                xlSheet.Range(第一 & 5 + 4 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5 & ":" & 第二 & 5 + 4 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5 + 位置6).Select()
                myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
                xlSheet.Range(第一 & 5 + 4 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5 & ":" & 第二 & 5 + 4 + 位置1 + 位置2 + 位置3 + 位置4 + 位置5).Select()
                myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
                With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
                With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
                myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
            Next
        End If
        xlSheet.Range("A3:B3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("C3:D3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("E3:F3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("G3:H3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("I3:J3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("K3:L3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("M3:N3").Select()
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeLeft) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeTop) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        With myExcel.Selection.Borders(xlEdgeRight) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlMedium : End With
        myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        xlSheet.Range("A3:B3").Select()
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 13421823 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
        xlSheet.Range("C3:L3").Select()
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .ThemeColor = xlThemeColorAccent1 : .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0 : End With
        xlSheet.Range("M3:N3").Select()
        With myExcel.Selection.Interior : .Pattern = xlSolid : .PatternColorIndex = xlAutomatic : .Color = 5296274 : .TintAndShade = 0 : .PatternTintAndShade = 0 : End With
        xlSheet.Columns("A:B").Select : With myExcel.Selection.Font : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = -0.249977111117893 : End With
        xlSheet.Columns("M:N").Select : With myExcel.Selection.Font : .ThemeColor = xlThemeColorAccent6 : .TintAndShade = -0.249977111117893 : End With
        xlSheet.Range("A1:N1").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 16 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Range("A2:N2").Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = False : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With : myExcel.Selection.Merge
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Size = 14 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False
            .Shadow = False : .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        xlSheet.Rows("1:2").Select : With myExcel.Selection.Font : .ColorIndex = xlAutomatic : .TintAndShade = 0 : End With
    End Sub
End Class