145k views
4 votes
What is wrong with the following Do loop?

Dim index As Integer = 1
Do While index <> 10 lstBox.Items.Add("Hello")
index += 2

1 Answer

5 votes

Final answer:

The given Do loop will result in an infinite loop.

Step-by-step explanation:

The problem with the given Do loop is that the condition 'index <> 10' will cause an infinite loop because the value of 'index' is not being updated inside the loop. As a result, the loop will continue indefinitely, adding 'Hello' to the 'lstBox' without ever reaching the exit condition.

User Ecoplaneteer
by
8.1k points