VB问题,编译时,出现子程序或函数错误是怎么回事,感觉是两个自定义事件wy wx 出问题,求帮助啊,下面是原代码
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = 70 Then
For i = 0 To 10
For u = 0 To 2
aa(i, u) = 0
bb(i, u) = 0
bb11(i, u) = 0
Next u
Next i
Image1.Left = Form1.ScaleWidth / 2 - Image1.Width / 2
Image2.Left = Image1.Left + Image2.Width
Image2.Top = Image1.Top - Image2.Height
Show
For i = 0 To 3
10
a = Int(Rnd(0.5) * 9)
b = Int(Rnd(0.5) * 3)
bb11(a, b) = 1
If bb11(a, b) = bb(a, b) Then GoTo 10 ' 当两个数组相同时,重新为A,B赋随机值
bb(a, b) = 1
Next i
For i = 0 To 8
For u = 0 To 2
Form1.PaintPicture Image3.Picture, i * Image3.Width, u * Image3.Height
Next u
Next i
xt = 150
yt = 150
End If
If xx1 = 0 Then
If KeyCode = 40 Then
Image2.Left = Image1.Left + Image2.Width
Image2.Top = Image1.Top - Image2.Height
Timer1.Enabled = True
xx1 = 1
yp = 150
xp = -150
End If
If KeyCode = 38 Then
Image2.Left = Image1.Left + Image2.Width
Image2.Top = Image1.Top - Image2.Height
Timer1.Enabled = True
xx1 = 1
yp = 150
xp = 150
End If
End If
If Image1.Left > 0 Then
If KeyCode = 37 Then
Image1.Left = Image1.Left - xt
If xx1 = 0 Then
Image2.Left = Image1.Left + Image2.Width '图像框2的左坐标右移图像框2宽度
End If
End If
End If
If Image1.Left < Form1.ScaleWidth - Image1.Width Then
If KeyCode = 39 Then
Image1.Left = Image1.Left + yt
If xx1 = 0 Then
Image2.Left = Image1.Left + Image2.Width
End If
End If
End If
End Sub
Private Sub Form_Load()
For i = 0 To 8
For u = 0 To 2
bb11(i, u) = 0
bb(i, u) = 0
aa(i, u) = 0
Next u
Next i
Image1.Left = Form1.ScaleWidth / 2 - Image1.Width / 2
Image2.Left = Image1.Left + Image2.Width
Show
Timer1.Enabled = False
Image2.Top = Image1.Top - Image2.Height
xx1 = 0
rig = 0
For i = 0 To 3
10
a = Int(Rnd(0.5) * 9)
b = Int(Rnd(0.5) * 3) 'a b 为赋随机值
bb11(a, b) = 1
If bb11(a, b) = bb(a, b) Then GoTo 10 ' 当两个数组相同时,重新为A,B赋随机值
bb(a, b) = 1
Next i
For i = 0 To 8
For u = 0 To 2
Form1.PaintPicture Image3.Picture, i * Image3.Width, u * Image3.Height
Next u
Next i
xt = 150
yt = 150
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End
End Sub
Private Sub Timer1_Timer()
Image2.Top = Image2.Top - yp
Image2.Left = Image2.Left - xp
For i = 0 To 8
For u = 0 To 2
If Image2.Top < (u + 1) * Image3.Height And Image2.Top > u * Image3.Height Then
If Image2.Left > (i + 1) * Image3.Width - 200 And Image2.Left < (i + 1) * Image3.Width + 200 Then
wx i, u
End If
End If
If Image2.Left < (1 + i) * Image3.Width And Image2.Left > i * Image3.Width Then
If Image2.Top < u * Image3.Height + Image2.Height And Image2.Top > u * Image3.Height Then
wx i, u
End If
End If
If Image2.Top < (u + 1) * Image3.Height And Image2.Top > u * Image2.Height Then
If Image2.Left < i * Image3.Width And Image2.Left > i * Image3.Width - Image2.Width Then
wx i, u
End If
End If
Next u
Next i
If Image2.Left > Image1.Left - Image2.Width And Image2.Left < Image1.Left + Image1.Width Then
If Image2.Top > Image1.Top - Image2.Height And Image2.Top < Image1.Top - Image2.Height + 200 Then
yp = -yp
End If
End If
If Image2.Left < 0 Then
Image2.Left = 0
xp = -xp
End If
If Image2.Left > Form1.ScaleWidth - Image2.Width Then
Image2.Left = Form1.ScaleWidth - Image2.Width
xp = -xp
End If
If Image2.Top < 0 Then
Image2.Top = 0
yp = -yp
End If
If Image2.Top > Form1.ScaleHeight Then
xx1 = 0
End If
End Sub
Sub wx(ByVal i, ByVal u)
If aa(i, u) < 2 Then
xp = -xp
aa(i, u) = aa(i, u) + 1
Form1.PaintPicture Image5.Picture, i * Image3.Width, u * Image3.Height
If aa(i, u) = 2 Then
rig = rig + 1
Form1.PaintPicture Image4.Picture, i * Image3.Width, u * Image3.Height
If bb(i, u) = 1 Then
Timer2.Enabled = True
Image6.Left = i * Image3.Width
Image6.Top = u * Image3.Height
End If
End If
If rig >= 27 Then
a = MsgBox("您还要继续吗?", vbYesNo, "您羸了")
If a = vbNo Then
End
Else
Form1_Load
Exit Sub
End If
End If
End If
End Sub
Sub wy(ByVal i, ByVal u)
If aa(i, u) < 2 Then
yp = -yp
aa(i, u) = aa(i, u) + 1
Form1.PaintPicture Image5.Picture, i * Image3.Width, u * Image3.Height
If aa(i, u) = 2 Then
rig = rig + 1
Form1.PaintPicture Image4.Picture, i * Image3.Width, u * Image3.Height
If bb(i, u) = 1 Then
Timer2.Enabled = True
Image6.Left = i * Image3.Width
Image6.Top = u * Image3.Height
End If
End If
If rig >= 27 Then
a = MsgBox("您还要继续吗?", vbYesNo, "您羸了")
If a = vbNo Then
End
Else
Form1_Load
Exit Sub
End If
End If
End If
End Sub