我看到你的代码了,想说点东西,希望你不要介意 。。。
先把你的代码贴出来,呵呵
================================================
p.Scale (0, 0)-(20, 20)
For z1 = -5 To 25
For z2 = -5 To 25
arr(z1, z2) = -1
Next z2
Next z1
l = 0
End Sub
Private Sub menu_exit_Click()
End
End Sub
Private Sub menu_restart_Click()
p.Cls
For z = 1 To 19
p.Line (1, z)-(19, z)
p.Line (z, 1)-(z, 19)
Next z
For z1 = -5 To 25
For z2 = -5 To 25
arr(z1, z2) = -1
Next z2
Next z1
l = 0
End Sub
Private Sub restart_click()
p.Cls
For z = 1 To 19
p.Line (1, z)-(19, z)
p.Line (z, 1)-(z, 19)
Next z
For z1 = -5 To 25
For z2 = -5 To 25
arr(z1, z2) = -1
Next z2
Next z1
l = 0
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub p_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If arr(CInt(X), CInt(Y)) = -1 And 0 < CInt(X) And CInt(X) < 20 And 0 < CInt(Y) And CInt(Y) < 20 Then
p.FillStyle = l
p.Circle (CInt(X), CInt(Y)), 0.4
arr(CInt(X), CInt(Y)) = l
l = (l + 1) Mod 2
End If
End Sub
================================================
你的菜单代码和按钮代码,是一样的,那你完全可以写一份代码,
我一般的做法是在 menu_restart_Click()中Call restart_Click()函数,
这样可以减少代码的维护难度 。。
你的 mousedown()中没有进行输赢的判断,当然你这也不是一个含有
人工智能的代码,不过你只是画圈,总不是太好吧 。。
==========================================
不过,敢于贴代码的都是勇者,希望你继续努力,
以后 我们多多交流吧 。。