0

Hi,

I want to add a button (ButtonCalculate) to make the user select this button to generate the loop for calculating the sum.

Private Sub TextBox1Integer_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1Integer.TextChanged
        
      Dim OddSum As Integer = 0 
        Try
            Dim CountTo As Integer = TextBox1Integer.Text
            For Index As Integer = 1 To CountTo
                If Index Mod 2 <> 0 Then
                    OddSum += Index
                End If
            Next
            Label1Output.Text = "Sum is: " & OddSum.ToString
        Catch ex As Exception
            MessageBox.Show("Error - Please Enter An Integer")
        End Try
    End Sub
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Alex_2011
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.