2014年12月5日 星期五

Z2X56-段2模C參考程式碼

Public Class Form1
    Private Sub CC3_DoubleClick(…) Handles CC3.DoubleClick
        ' 1 按2下
        CC3.Items.Add(CC2.Text)
        CC2.Focus()
        CC2.SelectAll()
    End Sub
    Private Sub Button2_Click(…) Handles Button2.Click
        ' 2 →
        Dim i As Integer
        For i = 0 To CC3.SelectedItems.Count - 1
            ListBox2.Items.Add(CC3.SelectedItems(i))
        Next
        For i = CC3.SelectedIndices.Count - 1 To 0 Step -1
            CC3.Items.RemoveAt(CC3.SelectedIndices(i))
        Next
    End Sub
    Private Sub Button3_Click(…) Handles Button3.Click
        ' 3 →
        Dim i As Integer
        For i = 0 To CC3.SelectedItems.Count - 1
            ListBox3.Items.Add(CC3.SelectedItems(i))
        Next
        For i = CC3.SelectedIndices.Count - 1 To 0 Step -1
            CC3.Items.RemoveAt(CC3.SelectedIndices(i))
        Next
    End Sub
    Private Sub Button4_Click(…) Handles Button4.Click
        ' 4 →
        Dim i As Integer
        For i = 0 To CC3.SelectedItems.Count - 1
            ListBox4.Items.Add(CC3.SelectedItems(i))
        Next
        For i = CC3.SelectedIndices.Count - 1 To 0 Step -1
            CC3.Items.RemoveAt(CC3.SelectedIndices(i))
        Next
    End Sub

    Private Sub Button5_Click(…) Handles Button5.Click
        ' 5 ↓
        For i = ListBox2.SelectedIndices.Count - 1 To 0 Step -1
            ListBox2.Items.RemoveAt(ListBox2.SelectedIndices(i))
        Next
    End Sub

    Private Sub Button6_Click(…) Handles Button6.Click
        '6 ←
        Dim i As Integer
        For i = 0 To ListBox3.SelectedItems.Count - 1
            CC3.Items.Add(ListBox3.SelectedItems(i))
        Next
        For i = ListBox3.SelectedIndices.Count - 1 To 0 Step -1
            ListBox3.Items.RemoveAt(ListBox3.SelectedIndices(i))
        Next
    End Sub

    Private Sub Button7_Click(…) Handles Button7.Click
        ' 7 ↑
        Dim i As Integer
        For i = 0 To ListBox4.SelectedItems.Count - 1
            CC2.Items.Add(ListBox4.SelectedItems(i))
        Next
        For i = ListBox4.SelectedIndices.Count - 1 To 0 Step -1
            ListBox4.Items.RemoveAt(ListBox4.SelectedIndices(i))
        Next
    End Sub

    Private Sub Button8_Click(…) Handles Button8.Click
        ' 8 ↑
        Dim k = CC3.SelectedIndex
        Dim k1 = k - 1
        If k = 0 Then k1 = CC3.Items.Count - 1
        Dim a = CC3.Text
        If (k < 0) Then Exit Sub
        CC3.Items.RemoveAt(k)
        CC3.Items.Insert(k1, a)
        CC3.SelectedIndex = k1
    End Sub

    Private Sub Button9_Click(…) Handles Button9.Click
        ' 9.修改 以 CC2的text 來改變 CC1.text
        CC1.Text = CC2.Text
    End Sub

    Private Sub Button10_Click(…) Handles Button10.Click
        ' 10 ↓
        Dim n = CC3.SelectedIndex
        If n >= CC3.Items.Count - 1 Then Exit Sub
        CC3.Items.Insert(n + 2, CC3.Items(n))
        CC3.Items.RemoveAt(n)
        CC3.SelectedIndex = n + 1
    End Sub

    Private Sub Button11_Click(…) Handles Button11.Click
        ' 11 顯示字型
        If ListBox2.SelectedIndex = -1 Then ListBox2.SelectedItem = CC1.Font.Name
        If ListBox3.SelectedIndex = -1 Then ListBox3.SelectedIndex = 0
        If ListBox4.SelectedIndex = -1 Then ListBox4.SelectedItem = "16"
        Dim 字型名稱 As String = ListBox2.SelectedItem
        Dim 字型樣式 As FontStyle
        Dim 字型大小 As Integer = Val(ListBox4.SelectedItem)
        Select Case ListBox3.SelectedItem
            Case "標準"
                字型樣式 = FontStyle.Regular
            Case "粗體"
                字型樣式 = FontStyle.Bold
            Case "斜體"
                字型樣式 = FontStyle.Italic
            Case "粗斜體"
                字型樣式 = FontStyle.Bold Or FontStyle.Italic
            Case "底線"
                字型樣式 = FontStyle.Underline
            Case "刪除線"
                字型樣式 = FontStyle.Strikeout
        End Select
        CC1.Font = New Font(字型名稱, 字型大小, 字型樣式)
    End Sub

    Private Sub Button12_Click(…) Handles Button12.Click
        ' 12 End
        MsgBox("56-模考2C卷")
        End
    End Sub
End Class