一道vb题(懂的解) n=0 For i=1 To3 For j=5 To 1 step -1 n=n+1 Next j, i Print n; j; i

2024-12-04 05:04:23
推荐回答(1个)
回答1:

如果按以下格式:
Private Sub Form_Load()
n = 0
For i = 1 To 3
For j = 5 To 1 Step -1
n = n + 1
Text3.Text = Text3.Text & vbCrLf & n & " - " & j & " - " & i
Next j
Next i
End Sub

结果是:n-j-i
1 - 5 - 1
2 - 4 - 1
3 - 3 - 1
4 - 2 - 1
5 - 1 - 1
6 - 5 - 2
7 - 4 - 2
8 - 3 - 2
9 - 2 - 2
10 - 1 - 2
11 - 5 - 3
12 - 4 - 3
13 - 3 - 3
14 - 2 - 3
15 - 1 - 3

如果按以下格式:
Private Sub Form_Load()
n = 0
For i = 1 To 3
For j = 5 To 1 Step -1
n = n + 1
Next j
Next i
Text3.Text = Text3.Text & vbCrLf & n & " - " & j & " - " & i
End Sub

结果是:n-j-i
15 - 0 - 4