We help IT Professionals succeed at work.

Do Loop example

daky
daky asked
on
Medium Priority
145 Views
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?
Comment
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
    Loop
   
    MsgBox x
   
End Sub

Author

Commented:
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

Commented:
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?

Author

Commented:
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?

Cheers,
daky
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.