English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

我是剛學VB的初學者
最近看到

For ......next的迴圈教學
但是後面有一題是叫我寫出這樣的程式

9 8 7 6 5 4 3 2 1
...8 7 6 5 4 3 2
......7 6 5 4 3
.........6 5 4
............5
(.......請把它視為空白@@)
請問怎麼用FOR.....NEXT寫出這樣的東西>

2006-12-16 13:01:38 · 2 個解答 · 發問者 阿幹 1 in 電腦與網際網路 程式設計

2 個解答

Private Sub Command1_Click()
For j = 4 To 0 Step -1
Print Space((4 - j) * 4);
For i = j To -j Step -1
Print i + 5;
Next i
Print
Next j
End Sub

2006-12-16 18:17:00 · answer #1 · answered by ? 5 · 0 0

請注意: 用不同的字體會影響到數字的對齊
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim buf As String
For i = 0 To 4
buf = Space(i)
For j = 9 - i To 1 + i Step -1
buf = buf & j
Next j
Print buf
Next i
End Sub

2006-12-17 22:28:37 · answer #2 · answered by JJ 7 · 0 0

fedest.com, questions and answers