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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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:

  1. Declare three variables
    intEndnum              Ending number provided by the user
    intCount                  Loop counter
    intSum                     Running total
  2. Get the ending number from the user. Assign the text property of your textbox to intEndNum

  3. Code the loop. A sample is given above.

  4. 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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education