国际象棋
大家看一下还有更简洁的方法来实现棋盘的问题
Option Explicit
Dim t As Integer, l As Integer, i As Integer, j As Integer, k As Integer
Private Sub Form_Click()
t = 0
For i = 1 To 8
l = 50
For j = 1 To 8
k = (i - 1) * 8 + j
Load Label1(k)
Label1(k).BackColor = IIf((i + j) Mod 2 = 0, QBColor(0), QBColor(15))
Label1(k).Visible = True
Label1(k).Top = t
Label1(k).Left = l
l = l + Label1(0).Width
Next j
t = t + Label1(0).Height
Next i
End Sub
Private Sub Label1_Click(Index As Integer)
Label1(Index) = Index
For i = 1 To 8
For j = 1 To 8
k = (i - 1) * 8 + j
If Label1(k).BackColor = QBColor(0) Then
Label1(k).BackColor = QBColor(15)
Else
Label1(k).BackColor = QBColor(0)
End If
Next j
Next i
End Sub