vb: 在do while 条件中怎么加 for的循环语句

2024-10-30 15:30:28
有2个网友回答
网友(1):

Private Sub command1_Click()
Dim a(9) As Integer, i As Integer, d(4) As Integer
Do While d(i) <> 6
For i = 1 To 9
a(i) = Fix(Rnd * 3) + 1
Next i
For i = 1 To 3
d(i) = a(3 * i - 2) + a(3 * i - 1) + a(3 * i)
If d(i) = 6 Then Exit For
Next i
Loop
Print d(i)
End Sub

网友(2):

Dim a(9) As Integer, i As Integer, d(3) As Integer
Do while d(i)<>6
  For i = 1 To 9
      a(i) = Fix(Rnd * 3) + 1
  Next i
  For i = 1 To  3
      d(i) = a(3*i-2)+a(3*i-1)+a(3*i)
  Next i
loop