Visual Basic 中学校 > Visual Basic サンプル集 > Visual Basic サンプル集目次 > Windows.Forms.ListBox >
選択されている項目を取得する
1.選択されている項目を1つ取得する例
TextBox1.Text = ListBox1.SelectedItem
2.選択されている項目のインデックスを1つ取得する例
TextBox1.Text = ListBox1.SelectedIndex
3.すべての選択されている項目を取得する例
Dim oItem As Object For Each oItem In ListBox1.SelectedItems
Label1.Text &= oItem & vbNewLine
Next
4.すべての選択されている項目のインデックスを取得する例
Dim Index As Integer For Each Index In ListBox1.SelectedIndices
Label1.Text &= Index & ", "
Next