I can't figure out how to fix this problem in my book
It's a debug problem, which means we have to fix a minor detail in the pre existing code
the program itself is supposed to count the number of positive, negative integers entered and zeros entered, via an inputbox.
the original code looks like this:
Private Sub enterButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles enterButton.Click ' displays the number of positive integers, the number of negative integers, ' and the number of zeros entered Dim inputNumber As String Dim number As Integer Dim positiveCounter As Integer Dim negativeCounter As Integer Dim zeroCounter As Integer Dim isConverted As Boolean Do While inputNumber <> "" isConverted = Integer.TryParse(inputNumber, number) If isConverted Then ' update appropriate counter If number > 0 Then positiveCounter = number + 1 ElseIf number < 0 Then negativeCounter = number + 1 Else zeroCounter = number + 1 End If Else MessageBox.Show("Please enter a number", "Number Entry", _ MessageBoxButtons.OK, MessageBoxIcon.Information) End If inputNumber = InputBox("Enter an integer. Click Cancel to end. ", _ "Number Entry", "0") Loop ' display counters positiveLabel.Text = Convert.ToString(positiveCounter) negativeLabel.Text = Convert.ToString(negativeCounter) zeroLabel.Text = Convert.ToString(zeroCounter) End Sub
I've tried a number of different things, by switching the loop to Loop until, loop while, etc. But I think it has something to do with the counter itself, I just don't know! Please help.