2 Replies - 370 Views - Last Post: 11 April 2013 - 05:17 PM Rate Topic: -----

#1 x RadicalAura x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-December 12

Loop Application Freezing

Posted 11 April 2013 - 05:02 PM

Why does my application freeze when I hit the button? Is it a runtime error? Sorry, I'm new to loops.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
'Display the numbers from 1 to 5
   Dim num As Integer
Do While num <> 6
   num = 1
   lstOutput.Items.Add(num)
   num += 1
Loop
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Loop Application Freezing

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3609
  • View blog
  • Posts: 12,409
  • Joined: 12-December 12

Re: Loop Application Freezing

Posted 11 April 2013 - 05:06 PM

You keep re-setting num to 1, then add 1 to it. So it goes 1,2,1,2,1,2,1,2,1,2,... Reaching 3 seems unlikely, and 6 is very optimistic :)

This post has been edited by andrewsw: 11 April 2013 - 05:09 PM

Was This Post Helpful? 0
  • +
  • -

#3 x RadicalAura x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-December 12

Re: Loop Application Freezing

Posted 11 April 2013 - 05:17 PM

Thank you! I fixed it and it seems to be working just fine now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1