What's the difference between Do While where the statement is the first line in the loop block and just the single While in VB.NET?
They don't seem to offer any difference in behavior.
In Visual Basic these are identical:
Dim foo As Boolean = True
While Not foo
Debug.WriteLine("!")
End While
Do While Not foo
Debug.WriteLine("*")
Loop
These are not; the do
executes once:
Dim foo As Boolean = True
While Not foo
Debug.WriteLine("!")
End While
Do
Debug.WriteLine("*")
Loop While Not foo
Do While Not …
can be written as Do Until
.
Commented
Apr 17, 2013 at 13:04
Do Until
. I've seen too may people accidentally throw infinite loops into production code with it.
In DO...WHILE, the code inside the loop is executed at least once
In WHILE Loop, the code inside the loop is executed 0 or more times.
Do While
executes first and then checks if valid. While
checks first and then executes.
while (1!=1){ echo 1}
will output nothing
But
do{echo 1} while (1!=1)
will output 1 once.
Mid(MyStr, 2) = "Hi"
want to guess what that does?