Is the loop structure in VB fast with the for statement or the do loog statement?

Updated on number 2024-05-11
4 answers
  1. Anonymous users2024-02-10

    After compiling to local, the fornext and doloop loops (including all other loops) use the same local **. The main reason for the speed difference between cycles is the execution speed of the cycle body**. If the circulation is very short (or even none), then as it was said upstairs, it depends on the conditions for exiting the loop.

    However, it is important to note that the "exit condition" here refers to a simple sentence like a < b, such as.

    do loop while custom function() = true

    In such a loop, the execution time of the custom function () should be counted in the time consumed by the loop body.

    So there is basically no difference in the execution speed of the loop structure itself (because the compilation results in the same local **), and if I have to say, theoretically doloop is slightly faster (imperceptibly) than fornext

    This is because at compile time for fornext, the compiler will use the doloop loop after the value of the added variable increases (i=1 to 10) and the exit condition is compared (if i=11 it exits the loop).

    This also explains why DoLoop can emulate ForNext but ForNext can't

  2. Anonymous users2024-02-09

    This is related to the number of loops to be looped and the algorithm.

  3. Anonymous users2024-02-08

    For the same loop, the speed of the cycle depends on the test of the termination loop condition, the abort condition test of the for loop only compares the size of the two numbers, and the test of the do loop is often only the comparison of the size, and even has other operations or tests, so from this point of view, the for loop should be faster than the do loop.

    Of course, this is my personal understanding and does not represent authority.

  4. Anonymous users2024-02-07

    do while i>1 'When i>1, the circulating body begins to know the answer.

    i=i+1 'Let i increase by one unit at a time.

    if i>20 then 'after increasing i, determine whether i is greater than 20exit do', if it is greater than 20, then jump out of the loop (exit do) end if'If not, the judgment statement is bypassed and the loop continues.

    loop.

    Visual Basic (VB) is a general object-based programming language developed by Microsoft Vision, which is a structured, modular, object-oriented, event-driven visual programming language that includes an event-driven mechanism to assist the development environment. is a language that can be used in Microsoft's own product development.

    "Visual" refers to the way to develop a graphical user interface (GUI) - you don't have to write a lot of ** to describe the appearance and position of interface elements, you just need to add pre-built objects to a point on the screen. "Basic" stands for Basic (Beginners All-Purpose Symbolic Instruction Code) language, which is the most widely used language in the history of computing technology.

    Visual Basic is derived from the Basic programming language. With a graphical user interface (GUI) and rapid application development (RAD) system, VB can easily connect to databases using DAO, RDO, ADO, or easily create Active X controls for efficient generation of type-safe and object-oriented applications. Programmers can easily build an application quickly using the components provided by VB.

Related questions
2 answers2024-05-11

The data source addnew itself is to add a line.,Of course, two lines appear when the landlord executes twice.,It should be placed on a line.,And then addnew's two parameters to two arrays on the line.,The usage is still used like this (field name,Content),It's just that the number of members of these two arrays is the same.,You can meet your requirements.,Try it.。

6 answers2024-05-11

vb. do...loop

The loop itself does not have an end loop condition, no matter what kind of operation is performed in the loop, as long as there are no syntax errors, it will always be executed, if its execution speed is too high, it will always occupy the CPU, resulting in crashes and other system problems; Right. do >>>More

6 answers2024-05-11

Save the following information in a "text document" with the name "1" echo off >>>More

32 answers2024-05-11

1.Wipe the surface of the model with a damp cloth 2Cut out the outline with a pen knife along the pattern or text of the sticker (this point is easy to be overlooked, in order to prevent errors in the manufacture of water stickers, some blank edges will be left, these blank spaces are best removed), soak in warm water for about 10 seconds, then take it out and put it aside for a few seconds. >>>More

4 answers2024-05-11

If you think it's cool, you can ignore the rest