Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim n As Integer, sout As Integer
Dim a(1 To 5, 1 To 5) As Integer
Dim Flags As String
Flags = "Right"
i = 1: j = 1
n = 1
Do While n <= 25
a(i, j) = n
Select Case Flags
Case "Right"
If j = UBound(a, 1) Then
Flags = "Down"
Else
Flags = "Right"
End If
Case "Down"
If j = UBound(a, 1) Then
Flags = "Left"
Else
Flags = "Right"
End If
Case "Left"
If j = LBound(a, 1) Then
Flags = "Down"
Else
Flags = "Left"
End If
End Select
Select Case Flags
Case "Right"
j = j + 1
Case "Down"
i = i + 1
Case "Left"
j = j - 1
End Select
n = n + 1
Loop
For i = 1 To 5
For j = 1 To 5
Print a(i, j);
Next
Print
Next
End Sub
[此贴子已经被作者于2006-5-4 23:21:06编辑过]