Visual Basic (2008 Express)
Rogue Value

Example : A sequence of exam marks is input, terminated by a rogue value of -1.

The number of marks greater than 50 is counted and output in a TextBox called txtAnswer.

 

Dim Mark As Integer
Dim
counter As Integer

'Initialise counter
counter = 0

Do

    'Input mark
    Mark = InputBox("Please enter mark")

    'Do not process the rogue value
   
If Mark <> -1 Then

        'Check to see if the mark is gretaer than 50
       
If Mark > 50 Then

        'Add 1 to counter
        counter = counter + 1

        End If

    End If

Loop Until Mark = -1

txtAnswer.Text = counter

 

 

   Back