Create a program called Sum of Numbers, with two buttons ( Enter numbers & Exit). The InputBox will be called Input Needed and will ask: Enter the positive integer value.
The answer will come in a message call Sum of Numbers stating: The sum of the number 1 through is
If the user enters a negative value, his application should display an error message. Use the following data:
Value Sum
5 15
10 55
20 210
100 5050
This is what I have so far, but I can't get the result to show in the MessageBox
Dim strUserInput
Dim IntUserInput As Integer
Dim i As Integer
strUserInput = InputBox("Enter a positive integer value", "Input Needed", 10)
If strUserInput <> String.Empty Then
Try
IntUserInput = CInt(strUserInput)
If IntUserInput < 0 Then
MessageBox.Show("Negative numbers are not accepted.")
Exit Sub
End If
'IntUserInput = (IntUserInput + i)
MessageBox.Show("Sum of Numbers", "The sum of the numbers 1 through" & (i + IntUserInput), MessageBoxButtons.OK)
Catch ex As Exception
MessageBox.Show("Quantity amount must be numeric.")
End Try
'show messages,
Else
End If
MessageBox.Show("Incorrect input", "You must enter a positive integer value", MessageBoxButtons.OK)