1、添加image1()控件數組,重要的是“控件數組”。保留image1(0)即可,其他的部分,程序運行時會自動添加。
2、添加command1
3、復制代碼,運行
4、實在不會就給我發QQ48201026(只有晚上在壹會兒,還是隱身。呵呵)
Dim b As Boolean
Dim c As Long
Private Sub Command1_Click()
If c = 0 Then Exit Sub
Command1.Enabled = False
Dim d As String
d = c
For i = 0 To 440
If d = Image1(i).Tag Then
Image1(i).Picture = LoadPicture("")
c = c - 1
If b = True Then
b = False
Else
b = True
End If
End If
Next i
Command1.Enabled = True
End Sub
Private Sub Form_Load()
Dim a As Long
a = 0
For i = 1 To 440
Load Image1(i)
Image1(i).Visible = True
Next i
For i = 0 To 440
Image1(i).Stretch = True
'Image1(i).Picture = LoadPicture("002.gif")
Image1(i).Width = 400
Image1(i).Height = 400
If i < 21 Then
Image1(i).Left = 600 + i * Image1(i).Width
Image1(i).Top = 600
Else
Image1(i).Left = 600 + (i Mod 21) * Image1(i).Width
If i Mod 21 = 0 Then
a = a + 1
End If
Image1(i).Top = 600 + Image1(i).Height * a
End If
Next i
For i = 0 To 20
Me.Line (600 + Image1(0).Width / 2, 600 + i * Image1(0).Height + Image1(0).Height / 2)-(600 + Image1(0).Width * 21 - Image1(0).Width / 2, 600 + i * Image1(0).Height + Image1(0).Height / 2)
Me.Line (600 + i * Image1(0).Width + Image1(0).Width / 2, 600 + Image1(0).Height / 2)-(600 + i * Image1(0).Width + Image1(0).Width / 2, 600 + Image1(0).Height * 21 - Image1(0).Height / 2)
Next i
Me.FillStyle = 0
Me.Circle (600 + Image1(0).Width * 3.5, 600 + Image1(0).Height * 3.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 10.5, 600 + Image1(0).Height * 3.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 17.5, 600 + Image1(0).Height * 3.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 3.5, 600 + Image1(0).Height * 10.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 10.5, 600 + Image1(0).Height * 10.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 17.5, 600 + Image1(0).Height * 10.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 3.5, 600 + Image1(0).Height * 17.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 10.5, 600 + Image1(0).Height * 17.5), 50, vbBlack
Me.Circle (600 + Image1(0).Width * 17.5, 600 + Image1(0).Height * 17.5), 50, vbBlack
b = True 'true 是白先黑後,false 是黑先白後
c = 0
Me.Width = 9870
Me.Height = 11070
Command1.Caption = "悔棋"
End Sub
Private Sub Image1_Click(Index As Integer)
If Image1(Index).Picture = LoadPicture("") Then
If b = True Then
Image1(Index).Picture = LoadPicture("002.gif")
b = False
Else
Image1(Index).Picture = LoadPicture("001.gif")
b = True
End If
c = c + 1
Image1(Index).Tag = c
Else
MsgBox "這裏已經有棋子了"
End If
End Sub