title: Trying to get SUM of ListBox selected items from local DataTable into a Label
body: <p>I have been searching for days, for any possible reference or suggestions and everything I've come across hasn't worked. </p>
  
  <p><strong>The goal:</strong></p>
  
  <p>User will select options in ComboBox1 that will then determine the available options in ComboBox2, then will populate a list of operations in ListBox1.</p>
  
  <p>When the user selects available operations in ListBox1, I need the output to be the sum of values (total time in minutes in this case) into a label for display. </p>
  
  <p>The data used in stored in a local db. So far everything works with my comboboxes and the listbox. </p>
  
  <p>Im attempting to get the Text value, of all selected items, in ListBox1 to output the numeric value in my table (column 4 "OperationsTime"), into a label that will display the sum of all the selections (Total Time In Minutes).</p>
  
  <p><strong>Some Things I have Tried From Other Posts:</strong></p>
  
  <ol>
  <li><pre><code> Label9.Text = ListBox1.ValueMember
  </code></pre></li>
  <li><pre><code> Label9.Text = ListBox1.ValueMember.ToString
  </code></pre></li>
  <li><pre><code> Label9.Text = CType(ListBox1.SelectedItem, DataRowView).Row.Item("OperationsTime").ToString
  </code></pre></li>
  </ol>
  
  <p>Attempted using Double:</p>
  
  <pre><code>         Dim Total As Double = 0
      For Each Time As Integer In ListBox1.SelectedItems
          Total += CDbl(Time.ToString.Substring(Time.ToString.LastIndexOf(",") + 1))
      Next
      Label9.Text = Total.ToString
  </code></pre>
  
  <p><strong>Screen Shot of the Table:</strong>
  <a href="https://i.stack.imgur.com/bDuAi.jpg" rel="nofollow noreferrer">Operations Data Table</a></p>
  
  <p><strong>Below is my code:</strong></p>
  
  <pre><code>Imports System.Data
  Imports System.Configuration
  Imports System.Data.SqlClient
  
  Public Class MainHome
      Private Function GetData(ByVal sql As String) As DataTable
          Dim constr As String = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\hartj\Documents\visual studio 2015\Projects\TIMEMATRIX2.0\TIMEMATRIX2.0\TMX.mdf;Integrated Security=True"
          Using con As SqlConnection = New SqlConnection(constr)
              Using sda As SqlDataAdapter = New SqlDataAdapter(sql, con)
                  Dim dt As DataTable = New DataTable()
                  sda.Fill(dt)
                  Dim row As DataRow = dt.NewRow()
                  row(0) = 1
                  row(1) = "Please Select"
                  dt.Rows.InsertAt(row, 0)
                  Return dt
              End Using
          End Using
      End Function
  
      Private Sub MainHome_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
          ComboBox1.DataSource = Me.GetData("SELECT  SizeId, SizeName FROM Size")
          ComboBox1.DisplayMember = "SizeName"
          ComboBox1.ValueMember = "SizeId"
          ComboBox2.Enabled = False
          ComboBox3.Enabled = False
      End Sub
  
      Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted
          ComboBox2.DataSource = Nothing
          ComboBox3.DataSource = Nothing
          ComboBox2.Enabled = False
          ComboBox3.Enabled = False
          If ComboBox1.SelectedValue.ToString() &lt;&gt; "0" Then
              Dim sql As String = String.Format("SELECT DetailLevelId, DetailLevelName FROM DetailLevel WHERE SizeId = {0}", ComboBox1.SelectedValue)
              ComboBox2.DataSource = Me.GetData(sql)
              ComboBox2.DisplayMember = "DetailLevelName"
              ComboBox2.ValueMember = "DetailLevelId"
              ComboBox2.Enabled = True
          End If
      End Sub
  
      Private Sub ComboBox2_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox2.SelectionChangeCommitted
          ListBox1.DataSource = Nothing
          ListBox1.Enabled = False
          If ComboBox2.SelectedValue.ToString() &lt;&gt; "0" Then
              Dim sql As String = String.Format("SELECT OperationsId, OperationsName, OperationsTime FROM Operations WHERE DetailLevelId = {0}", ComboBox2.SelectedValue)
              ListBox1.DataSource = Me.GetData(sql)
              ListBox1.ValueMember = "OperationsName"
              ListBox1.ValueMember = "OperationsTime"
              ListBox1.Enabled = True
  
              Label9.Text = CType(ListBox1.SelectedValue, Integer).ToString
              'Label.Text = CType(cbbank.SelectedItem, DataRowView).Row.Item("Account").ToString
          End IF
      End Sub
  </code></pre>