2014-02-24 94 views
-1

下面我有一個數組,在我的設計中,我有一個包含10個選項的檢查列表框。例如,如果框1和2被選中,我只想打印索引0和1。我有一個打印所有數組成員(包含在下面)的按鈕,這就是我想打印只有選定的項目。我曾嘗試使用開關,但該文件已損壞,我迷路了。謝謝。 (語言VB)如何根據某些檢查框打印某些索引

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
btn1.Click 

    Dim strDecimal(9) As String 

      strDecimal(0) = FormatPercent(0.0146175) 
      strDecimal(1) = FormatPercent(0.0345324585) 
      strDecimal(2) = FormatPercent(0.09324543575) 
      strDecimal(3) = FormatPercent(0.07346475) 
      strDecimal(4) = FormatPercent(0.0772346615) 
      strDecimal(5) = FormatPercent(0.42234234654) 
      strDecimal(6) = FormatPercent(0.6246264664) 
      strDecimal(7) = FormatPercent(0.4524642234) 
      strDecimal(8) = FormatPercent(0.6876543534) 
      strDecimal(9) = FormatPercent(0.6876543534) 

    For num As Integer = 0 To strDecimal.Length - 1 
     listArrays.Items.Add(strDecimal(num)) 
    Next 
End Sub 

Private Sub clearList() 
    listArrays.Items.Clear() 
    End Sub 

    Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles btn2.Click 
    clearList() 
    End Sub 
+1

沒有代碼有輸出陣列的任何地方。顯示您的「開關」(稱爲CASE聲明,如果這就是您的意思)發送到文件或無論如何。很難幫助我們無法看到的代碼。 – Plutonix

回答

0

您使用的是CheckedListBox,想知道哪些項目經過假設:

Private Sub btn3_Click(sender As Object, e As EventArgs) Handles btn3.Click 
    For Each itm As String In listArrays.CheckedItems 
     Debug.Print(itm) 
    Next 
End Sub