Dim a(1 To 1000) As String
Const n = 4
Private Sub Form_Load()
Dim x As Integer, s As String
Dim b(1 To n * n) As Boolean
Randomize
For i = 1 To n ‘随机产生n个位置,使得这些位置表示未被涂黑
If b(x) = False Then
a(x) = "0"
b(x) = True
Else
i = i - 1
End If
Next i
‘将其余位置赋值为“#”,存入数组a相应的位置中,并将结果按n行n列的方式显示在列表框list1上,代码略
End Sub
Private Sub Command1_Click()
Dim s As String, jg As String, ch As String
s = "HAOXUEXIHAODUSHU"
For i = 1 To n * n Step n
List2.AddItem Mid(s, i, n)
Next i
For i = 1 To n
For j = 1 To n * n
If a(j) = "0" Then
ch = Mid(s, j, 1)
ch =
jg = jg + ch
End If
Next j
Call turn(n) ‘调用过程turn,完成矩阵顺时针旋转90度
Next i
Label1.Caption = jg
End Sub
Sub turn(x As Integer)
Dim i As Integer, j As Integer
Dim c(1 To n * n) As String
For i = 1 To x
For j = 1 To x
c((i - 1) * x + j) =
Next j
Next i
For i = 1 To n * n
a(i) = c(i)
Next i
End Sub