在Visual Basic中将Next语句转换为Loop语句

时间:2009-06-07 01:40:11

标签: vb.net loops

嘿大家好我的朋友和我正在重新学习Visual Basic,我们对这段代码感到难过。

For intAsterisks As Integer = 0 To intLine - 1
  lblAsterisks.Text = lblAsterisks.Text + "*"
Next

我们需要能够将For Next代码转换为Do循环代码。有人可以帮助我们吗?

3 个答案:

答案 0 :(得分:3)

dim intAsterisks as integer = 0
Do While intAsterisks < intLine
    'Do stuff
    intAsterisks = intAsterisks + 1
Loop

答案 1 :(得分:3)

我会问一个问题“为什么你需要转换它?”

Dim i as Integer = 0
Do While i < intLine
    lblAsterisks.Text = lblAsterisks.Text + "*"
    i = i + 1
Loop

答案 2 :(得分:0)

dim i as integer
Private sub command1_click()
  For i = 0 to 30 Step 1
  Print (i)
  next 
end sub