2023-05-25 14:18:12 +02:00
== Why is this an issue?
A ``++Do ... Loop++`` without a ``++While++`` or ``++Until++`` condition must be terminated by an unstructured ``++Exit Do++`` statement. It is safer and more readable to use structured loops instead.
=== Noncompliant code example
[source,vbnet]
----
Module Module1
Sub Main()
Dim i = 1
Do ' Non-Compliant
If i = 10 Then
Exit Do
End If
Console.WriteLine(i)
i = i + 1
Loop
End Sub
End Module
----
=== Compliant solution
[source,vbnet]
----
Module Module1
Sub Main()
For i = 1 To 9 ' Compliant
Console.WriteLine(i)
Next
End Sub
End Module
----
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Use a structured loop instead.
2021-09-20 15:38:42 +02:00
endif::env-github,rspecator-view[]