We help IT Professionals succeed at work.

Do Loop example

daky asked
Medium Priority
Last Modified: 2010-05-02
How to make do-loop in vb? I heared that using doloop circles crashes windows :) So, how to do that?
Watch Question

This is the Do Loop sintax:

Private Sub Form_Load()
    Dim x As Integer
    x = 0
    Do While x < 5
        x = x + 1
    MsgBox x
End Sub


Yes it works but it should be * instead of + at
Do While x < 5
x = x * 1          'it was +

and my Windows almost dodge it :) Thats why not A graded

Daky, the changes you suggest making to the code make no sense.  Multiplying a number by itself gives the same number (or in this case zero, since that is the starting value of x.)  You asked for an example of a Do loop (why I don't know because it is documented adequately in the online help) then when you get a perfectly good example, you make a nonsensical change to the code (resulting in an infinite loop, which won't crash your computer but will make your program useless and require Ctrl-Alt-Delete to fix) and then you grade EstebanFG with a B.  Why, because he cannot read your mind?


I don't really know. But when I run what he says, I just get msgbox 5. I press ok, and then nothing happen. I just want to make program which will 100% crash someone computer. First it opens 100 command prompts, and then it loop infinitley, so ctrl-alt-delete wont help. Good idea, isn't it?

If i would've known that what you wanted was to crash someone's computer, instead of avoiding crashing (like most people would), they I would've given you some other example. (ie. shelling thousands of instances of command prompt might do it, depending on the operating system).

oh well, thanks for the B!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.