vb.net Code:
Public Function SumOfIntegers(ByVal int As Integer) As Integer 'You do it this way because a function returns a value, your answer, and you can easily put your integer from the textbox into the function.
Dim sum As New Integer ' This is your total sum
For i = 1 To int ' For every number from 1 to your integer, i = that number, this is a loop that will happen for each "i"
'This is the only line of code you need, think about your question.... you take 1, then add 2, then add 3, the sum would be the previous number before adding the next number which would be "i"
sum += i
Next
Return sum ' This returns your final value
End Function
' To call the function you will have to do this... Most Likely in a button.click event that will be below your text box.
Textbox1.Text = SumOfIntegers(Textbox1.Text)