hello, my problem is with the calcbutton. I want it to take all of the numbers inputed by the users and give me a running total in the evenlabel and oddlabel labels I have created. I need for the code to select all the items in the listbox, decide which is odd and which is even and add the odds and evens.
I have given up now after hours of tries, here is what I am left with. Thanks.
Candice
CODE
Public Class Form6
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub clearbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearbutton.Click
ListBox1.Items.Clear()
End Sub
Private Sub DeleteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteButton.Click
If ListBox1.SelectedIndex >= 0 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
End Sub
Private Sub addButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles addButton.Click
Dim isconverted As Boolean
Dim val As Integer
isconverted = Integer.TryParse(inputtextbox.text, val)
If isconverted Then
ListBox1.Items.Add(inputtextbox.Text)
inputtextbox.Clear()
inputtextbox.Focus()
Else : MessageBox.Show("Invalid Input. Enter and Integer >0.", "Invalid Input", MessageBoxButtons.OK)
inputtextbox.Focus()
inputtextbox.Clear()
End If
End Sub
Private Sub CalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalcButton.Click
Dim val As Integer
Dim totalevens As Integer = 0
Dim totalodds As Integer = 0
Dim max As Integer = ListBox1.Items.Count - 1
For i As Integer = 0 To max
ListBox1.SelectedIndex = 1
val = Integer.Parse(ListBox1.SelectedItem.ToString)
If val Mod 2 = 0 Then
evenlabel.Text = 1
Else
oddlabel.Text = 1
End If
Next
End Sub
End Class