add numbers from listbox to a textbox
-
I am trying to add numbers from a listbox to to make a total in a texbox its working with vb6 but not with vb.net that what I did and it's not working Dim sum As Integer Dim i As Integer sum = 0 i = 0 For i = 0 To ListBox2.Items.Count - 1 sum = sum + ListBox2.Items(ListBox2.SelectedIndex) Next i TextBox5.Text = sum
-
I am trying to add numbers from a listbox to to make a total in a texbox its working with vb6 but not with vb.net that what I did and it's not working Dim sum As Integer Dim i As Integer sum = 0 i = 0 For i = 0 To ListBox2.Items.Count - 1 sum = sum + ListBox2.Items(ListBox2.SelectedIndex) Next i TextBox5.Text = sum
Try specifying the property of the object you are referencing in: sum = sum + ListBox2.Items(ListBox2.SelectedIndex). In VB6 each data type had a default property, and I don't think VB.NET has this so you need to indicate which property you are reading from. Is it numeric? HTH Andy