How do I use a do loop to find the sum of 5 arbitrary numbers with VB programming?

Updated on technology 2024-03-21
8 answers
  1. Anonymous users2024-02-07

    Right!

    The divisible 5 between 1 and 40 is:

    5, 10, 15, 20, 25, 30, 35, 40 and their sum is 180.

    dim n as integer

    sum = 0

    n = 1do while n <= 40

    if n mod 5 = 0 then sum = sum + nn = n + 1

    loopprint sum

  2. Anonymous users2024-02-06

    do while...loop and do....The only difference between loop while is that when the condition is false, do....loop while will be executed one more time.

  3. Anonymous users2024-02-05

    The following 7 loops can achieve the same result (replacing 100 with the input n can achieve the sum of circles and circles of any integer):

    s=0for i=2 to 100 step 2s=s+i

    next i

    ss=0for i=100 to 2 step -2s=s+i

    next i

    ss=0i=0do

    i=i+2s=s+i

    loop while i<100

    ss=0i=0

    do while i<100

    i=i+2s=s+i

    loop ss=0i=0

    do until i=100

    i=i+2s=s+i

    loop ss=0i=0

    doi=i+2

    s=s+iloop until i=100

    ss=0i=0

    while i<100

    i=i+2s=s+i

    wend? s

  4. Anonymous users2024-02-04

    This has to be asked, it's really a day, I'm going to report you.

  5. Anonymous users2024-02-03

    Do your homework yourself.

  6. Anonymous users2024-02-02

    1. VB programming takes Visual Basic Chinese Simplified Chinese version as the language background, introduces Visual Basic programming technology in simple terms, and basically covers the common content of Visual Basic programming.

    2. VB programming is divided into 14 chapters, including development environment, language basics, arrays and processes, common controls, menu design, file processing, ActiveX controls, database programming, graphic programming, multi-** programming, network programming, API functions and registry, installation program production and comprehensive examples.

    3. In order to facilitate readers' learning, "VB Programming" provides multiple courseware, as well as all sources of example questions and practice questions.

    4. VB programming can be used as a textbook for computer and related majors in colleges and universities, and is suitable for self-learning by programming enthusiasts.

  7. Anonymous users2024-02-01

    private sub command1_click()dim a as long 'Smaller numbers between 1-100 dim b as long'Larger numbers between 1-100 dim c as long

    a =b = 'text control to fill in the range you need do while a < = b

    c = c + a'If you don't want to include a, b can change a<=b in the previous sentence to aa = a+1

    loopmsgbox & "with" & "The sum of all integers is:" & cend sub

  8. Anonymous users2024-01-31

    The problem is not clear.

    Is it the sum between any two numbers you specify, or the sum between any two random numbers generated by the system?

    The former is directly qualified by two variables, and the loop exit condition is to reach the maximum number of exits and output the result. Very simple.

    The latter uses a random function to generate two numbers, judging the smallest number and the largest number, starting from the smallest number and adding to the largest number in a loop to exit.

Related questions
6 answers2024-03-21

VB design.

Introduction. What is required. >>>More

6 answers2024-03-21

Add 2 buttons, 2 textboxes, 1 listbox, and you can't go wrong. >>>More

7 answers2024-03-21

The last sentence is wrong, you have already swapped the values of the original b and c in the second if sentence, which means that the value of a must be greater than the value of c, and at this time, the value of a is not necessarily greater than the value of b, so this is not good.

2 answers2024-03-21

Summary. The flow lamp program uses an array to store the state of each lamp, and realizes the flow lamp effect by looping through the array, and changes the state of the lamp each time it cycles, so as to achieve the flow lamp effect. >>>More

8 answers2024-03-21

If the landlord is looking for the textbook for the class, it is not helping the landlord, the book is not good, and no one has to do the electronic version. >>>More