Option Strict On Option Explicit On Public Class frmMain 'Warning! This program does no check for non-numeric inputs. Try fixing this at home '(fairly easy) Private Sub btnAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAverage.Click Dim num As Double = 0 Dim count As Integer = 0 Dim sum As Double = 0 'Prompt for the input dialog box Dim prompt As String = "Enter a nonnegative number. " & "Enter -1 to terminate entering numbers." 'Asks the user for the first number num = CDbl(InputBox(prompt, "Enter a Number")) 'While the user has not entered negative 1 Do While num <> -1 'adds 1 to the counter variable count += 1 'Adds the number to the total sum sum += num 'Takes in the user's input again num = CDbl(InputBox(prompt, "Enter a number")) Loop 'If the user has entered in no numbers, say so, otherwise output the average If count > 0 Then MessageBox.Show("Average: " & CStr(sum / count), "Average") Else MessageBox.Show("No numbers were entered.", "No Numbers Were Entered") End If End Sub End Class