I have this teacher that doesn't offer any help and gives things that are not in the book. Even though my problem is simple I am also a beginner at this.
I'm having trouble with a loop the accumulates odd numbers but excludes the numbers input into the to input text boxes.
Say I put 1 in the lesser text box and 6 in the greater text box. How would I go about accumulating all odd numbers between 1 and 6. They would be 3 and 5 leaving me with a sum of 8 but im getting 9 because i can't exclude the inputs.
My code is
Code:Private Sub calcBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calcBtn.Click Dim SumInteger As Integer = 0 Dim lesserInteger As Integer = 0 Dim greaterInteger As Integer = 100 With Me lesserInteger = Integer.Parse(.lesserTB.Text) greaterInteger = Integer.Parse(.greaterTB.Text) Do While lesserInteger <= greaterInteger SumInteger += lesserInteger lesserInteger += 2 Loop .answerlbl.Text = SumInteger.ToString("N") End With End Sub




Reply With Quote