The user enters an integer into a text box and clicks on the Calculate button. The application will sum all of the integers from 1 to the number entered and display the sum in a label. The sum of numbers is the sum of all the numbers from 1 to the ending number. For example, if the user enters 3, the sum of numbers is 1 + 2 + 3 = 6. If the user enters 5, the sum of numbers is 1 + 2 + 3 + 4 + 5 = 15. Your program should work for any integer entered by the user.
The user enters an integer into a text box and clicks on the Calculate button. The application will sum all of the integers from 1 to the number entered and display the sum in a label.
The sum of numbers is the sum of all the numbers from 1 to the ending number. For example, if the user enters 3, the sum of numbers is 1 + 2 + 3 = 6. If the user enters 5, the sum of numbers is 1 + 2 + 3 + 4 + 5 = 15. Your program should work for any integer entered by the user.
Use a loop to calculate the sum of numbers. You will need to initialize the variables and assign appropriate values. Get the value for intEndNum from the textbox. After the loop has run, display intSum in the label.
Here is one way to code the loop:
For intCount = 1 To intEndNum
intSum = intSum + intCount
Next
Calculate Button Click-Event Procedure
You may find following these steps helpful:
- Declare three variables
intEndnum Ending number provided by the user intCount Loop counter intSum Running total - Get the ending number from the user. Assign the text property of your textbox to intEndNum
- Code the loop. A sample is given above.
- Display the running total. Assign intSum to the text property of your label.
![Sum of Numbers
DIRECTIONS:
Enter an integer for the Ending Number in the text box
below and click on the Calculate button. The sum of
numbers 1 through the number that you entered will
be calculated and displayed.
Ending Number:
Sum of Numbers:
Calculate
X
Exit](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe74060ca-e7d0-4b77-aa4a-88ebc9ee2751%2F3276f270-fb18-4138-8c78-2489c2be0008%2Fgp7y4c4_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)