| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1161 人关注过本帖
标题:VB问题,编译时,出现子程序或函数错误是怎么回事,感觉是两个自定义事件wy ...
取消只看楼主 加入收藏
榴紫丫
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:33
专家分:135
注 册:2011-11-3
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:1 
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
            Print

            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
        Print
        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
搜索更多相关主题的帖子: 子程序 
2011-12-22 16:14
榴紫丫
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:33
专家分:135
注 册:2011-11-3
收藏
得分:0 
变量定义 Dim xx1 As Byte
    Dim yp As Integer
    Dim xp As Integer
    Dim aa(50, 50) As Integer
    Dim xt As Integer
    Dim yt As Integer
    Dim bb(10, 10) As Integer
    Dim bb11(10, 10) As Integer
    Dim rig As Integer
这个是最后面的代码 Private Sub Timer2_Timer()
 Image6.Visible = True
        Image6.Top = Image6.Top + 100
        If Image6.Left > Image1.Left - Image6.Width And Image6.Left < Image1.Left + Image1.Width Then
            If Image6.Top > Image1.Top - Image6.Height And Image6.Top < Image1.Top Then
                Image6.Visible = False
                Timer2.Enabled = False
                xt = xt + 50
                yt = yt + 50
            End If
        End If
End Sub
模块中自定义事件 wx 和 wy 并在Private Sub Timer1_Timer()之中对其调用  这样修改后还是不行啊还是一样的问题
2011-12-23 12:42
快速回复:VB问题,编译时,出现子程序或函数错误是怎么回事,感觉是两个自定义事 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018994 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved