How to create Do loop in vb.net
2106
22-Dec-2015
I want to use Do loop in vb.net how to do this.
Aryan Kumar
06-Jul-2023Sure, I can help you with that. Here are the steps on how to create a do loop in VB.NET:
Do WhileorDo Untilstatement to control the loop.Exit Dostatement to exit the loop early.Here is an example of how to create a do loop in VB.NET:
VB.Net
This code will print the numbers from 1 to 9 on the console.
The
Do WhileandDo Untilstatements are similar, but they differ in the condition that is evaluated before the loop body is executed. TheDo Whilestatement will execute the loop body as long as the condition isTrue, while theDo Untilstatement will execute the loop body as long as the condition isFalse.The
Exit Dostatement can be used to exit the loop early. TheExit Dostatement will cause the loop to terminate immediately, regardless of the value of the loop control variable.Here are some of the advantages of using do loop in VB.NET:
Here are some of the disadvantages of using do loop in VB.NET:
For Next.Overall, do loop is a versatile and easy-to-use looping construct in VB.NET. It is a good choice for repeating a block of code an indefinite number of times.
Anonymous User
22-Dec-2015It repeats the enclosed block of statements while a Boolean condition is True or until the condition becomes True. It could be terminated at any time with the Exit Do statement.