Having trouble when executed. Can someone point me the right direction?

Public Class Form1

Private Sub btnEnterNumber_Click(sender As Object, e As EventArgs) Handles btnUserInput.Click
    'This will sum of the numbers
    Dim strUserInput As Integer
    Dim intUserInput As Integer 'Number entered by user
    Dim intSum As Integer = 0



    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


            MessageBox.Show("Sum of Numbers", "The sum of numbers 1 through" & (intSum + intUserInput), MessageBoxButtons.OK)

        Catch ex As Exception
            MessageBox.Show("Quanity amount must be numeric.")

        End Try
    Else
        MessageBox.Show("Incorrect input", "You must enter a positive integer value", MessageBoxButtons.OK)
    End If



End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
    Me.Close()
End Sub

End Class

could'nt understand this, suggests you to compile step by step...... and see the solution at each step so that you can get that troublshoot point in u'r code .

Your strUserInput should be a string, so:

Dim strUserInput As String

You need to take "Dim intSum As Integer = 0" out of the button click event, otherwise you always set it back to 0.

Do not understand, what do you want? At the calling of MessageBox.Show, you have interchanged the Prompt and Title argument values.

But in case of addition, I do not understand, what did you try to show in messagebox. If you try to show the inputted value, why do you want to add intUserInput with intSum. (intSum + intUserInput) is always serve you the same value as intUserInput, because intSum is always 0.
I think that, as per your MessageBox i.e.MessageBox.Show("Sum of Numbers", "The sum of numbers 1 through" & (intSum + intUserInput), you tried to show the summation of the numbers from '1' to the inputed numbers. As example, if you input the number '5', the message box shows '15' i.e the result of 1+2+3+4+5=15.
if so, you have to make a Loop for addition.
I am tring here some modification of yours.

Private Sub btnEnterNumber_Click(sender As Object, e As EventArgs) Handles btnUserInput.Click
    'This will sum of the numbers
    Dim strUserInput As String
    Dim intUserInput As Integer 'Number entered by user
    Dim intSum As Integer = 0
    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

            For Each i As Integer = 1 To intUserInput
                intSum +=i
            Next

            MessageBox.Show(String.Format("The sum of numbers 1 through {0} is {1}.", intUserInput, intSum), "Sum of Numbers", MessageBoxButtons.OK)
        Catch ex As Exception
            MessageBox.Show("Quanity amount must be numeric.")
        End Try
    Else
        MessageBox.Show("You must enter a positive integer value", "Incorrect input", MessageBoxButtons.OK)
    End If
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
    Me.Close()
End Sub

Hopefull, it could be help you.

Thank you all for the help. I was really confuse but it did help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.