以下Click事件有什么问题?

时间:2013-09-18 17:26:23

标签: vb.net

Private Sub btnRunDemo_Click(ByVal sender As System.Object, By Val e As System.EventArgs) Handles btnRunDemo.Click

  Dim count As Integer = 0

  Do While count > 10
      1stOutput.Items.Add("Hello")
      count += 1

  Loop
End Sub

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:2)

如果While>10设置为count,则0不会进入该位置。您需要使用Until

While这里的意思是“只要数量大于10就做循环”。但是你将count设置为0,所以它不会大于10,所以它不会进入循环。

Private Sub btnRunDemo_Click(ByVal sender As System.Object, By Val e As System.EventArgs) Handles btnRunDemo.Click

  Dim count As Integer = 0

  Do Until count > 10
      1stOutput.Items.Add("Hello")
      count += 1

  Loop
End Sub