Do while Loop

Submitted by: 

A do while loop is a control flow statement that allows code to be executed once based on a given boolean condition. In visual basic, you can use do while loop structure when you want to repeat a set of statements of an indefinite number of times, until a condition is satisfied.


Do While condition
[ statements ]
[ Continue Do ]
[ statements ]
[ Exit Do ]
[ statements ]

The Do while loop evaluate something that is true

  1. Dim num As Integer
  3. Do While num < 20
  4. num = num + 1
  5. MsgBox(num)
  6. Loop

Code Explanation:
1. Declare num variable as Integer
2. Then we use the Do While Loop to check if num is less than twenty
3. If less than twenty, it is true
4. Since it is true, we increment num by 1
5. Until it reaches 20 then, the statement will become false
6. Then we display the current value of num.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.