Basic Stuff..

   For i As Integer = 0 To ListBox1.SelectedItems.Count - 1

            MsgBox(ListBox1.SelectedItems.Item(i))

   Next i

 

 

VB6 METHOD..FYI…

For i = 0 To File1.ListCount - 1
    If File1.Selected(i) = True Then
         LoadIndividual (File1.List(i))
    End If
  Next i

 

            'Loop through the listbox and if the item in the listbox

            'matches the ExamToFind variable, then select it

            For p = 0 To lstExams.Items.Count - 1

                If lstExams.Items(p) = ExamToFind Then

                    lstExams.SelectedIndex = p

                End If

            Next

 

 

 

    ListBox1.Items.Add("Steve")

    ListBox1.Items.Add("Rebee")

    ListBox1.Items.Add("Lee")

 

    ListBox1.SetSelected(1, True)

 

    Dim i As Integer

    For i = 0 To ListBox1.Items.Count - 1

      If ListBox1.SelectedIndex = i Then

        MessageBox.Show(ListBox1.SelectedItem.ToString)

      End If

    Next i

 

 

      ‘Remove an item from a ListBox               

    Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick

        ListBox1.Items.Remove(ListBox1.SelectedItem)

        ListBox1.Refresh()

    End Sub

 

 

Straight From Microsoft Help…

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        ' Create an instance of the ListBox.

        Dim listBox1 As New ListBox()

        ' Set the size and location of the ListBox.

        listBox1.Size = New System.Drawing.Size(300, 300)

        listBox1.Location = New System.Drawing.Point(10, 10)

        ' Add the ListBox to the form.

        Me.Controls.Add(listBox1)

        ' Set the ListBox to display items in multiple columns.

        listBox1.MultiColumn = True

        ' Set the selection mode to multiple and extended.

        listBox1.SelectionMode = SelectionMode.MultiExtended

 

        ' Shutdown the painting of the ListBox as items are added.

        listBox1.BeginUpdate()

        ' Loop through and add 50 items to the ListBox.

        Dim x As Integer

        For x = 1 To 50

            listBox1.Items.Add("Item " & x.ToString())

        Next x

        ' Allow the ListBox to repaint and display the new items.

        listBox1.EndUpdate()

 

        ' Select three items from the ListBox.

        listBox1.SetSelected(1, True)

        listBox1.SetSelected(3, True)

        listBox1.SetSelected(5, True)

 

        ' Display the second selected item in the ListBox to the console.

        System.Diagnostics.Debug.WriteLine(listBox1.SelectedItems(1).ToString())

        ' Display the index of the first selected item in the ListBox.

        System.Diagnostics.Debug.WriteLine(listBox1.SelectedIndices(0).ToString())

 

    End Sub

 

 

 

Combine 2 Data Table Fields into 1, then bind that 1 field to a ListBox

 

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Create A Table *********************************************

        Dim dt As New DataTable()

        Dim dr As DataRow

 

        dt.Columns.Add(New DataColumn("vAge", GetType(Int32)))

        dt.Columns.Add(New DataColumn("LastName", GetType(String)))

        dt.Columns.Add(New DataColumn("FirstName", GetType(String)))

 

        Dim i As Integer

        For i = 0 To 8

            dr = dt.NewRow()

            dr("vAge") = i

            dr("LastName") = " My Last " & i.ToString()

            dr("FirstName") = " My First " & i.ToString

            dt.Rows.Add(dr)

        Next i

 

        '*************************************************************

 

        'Add a new column to the table.  The column is FullName,

        'the combination of the Last & First name fields

        Dim DynColumn As New DataColumn()

        With DynColumn

            .ColumnName = "FullName"

            .DataType = System.Type.GetType("System.String")

            .Expression = "LastName+' '+FirstName"

        End With

        'objDs.Tables(0).Columns.Add(DynColumn)

        dt.Columns.Add(DynColumn)

        '*******************************************************

 

        ListBox1.DataSource = dt

        ListBox1.DisplayMember = "FullName"

 

    End Sub