| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 487 人关注过本帖
标题:新人求助,俄罗斯方块,求指点,解惑
只看楼主 加入收藏
as9876
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2023-5-11
结帖率:0
收藏
 问题点数:0 回复次数:1 
新人求助,俄罗斯方块,求指点,解惑
新人求助,俄罗斯方块,vba写的,不会改了
求助,最近学着编写了用vba俄罗斯方块,在wps2019表格里写的,方向键相应正常,在另一个电脑的excel2010下运行,方向键不响应,想请教一下,是vba在wps和excel里的差异造成的么,不知道从什么地方、怎么改起,大侠们帮着解惑,不胜感激。。。

图片附件: 游客没有浏览图片的权限,请 登录注册
excel练习-俄罗斯方块23.4.28.zip (50.21 KB)


Private Sub Workbook_Open()
Sheet1.Clear
Application.OnKey "{up}", "sheet1.UP"
Application.OnKey "{down}", "sheet1.DOWN"
Application.OnKey "{right}", "sheet1.RIGHT"
Application.OnKey "{left}", "sheet1.LEFT"
Range("A1").Select
End Sub
Sub main()
Dim Yanse As Integer
Cells(4, 5).Resize(20, 10).Interior.ColorIndex = 2
Cells(2, 9) = 0
Speed = 500
100:
No = Int(Rnd * 7) + 1
Zt = Int(Rnd * 4) + 1
Yanse = Int(Rnd * 7) + 1
Select Case Yanse
    Case Is = 1
        Color = 33
    Case Is = 2
        Color = 44
    Case Is = 3
        Color = 10
    Case Is = 4
        Color = 46
    Case Is = 5
        Color = 41
    Case Is = 6
        Color = 43
    Case Is = 7
        Color = 26
End Select
X = 4
Select Case No
    Case Is = 1
        Y = Int(Rnd * 10) + 5
    Case Is < 4
        Y = Int(Rnd * 9) + 5
    Case Is < 7
        Y = Int(Rnd * 8) + 5
End Select
Tetris CInt(No), CInt(Zt), CInt(Color), CInt(X), CInt(Y)
Hx = Minh(CInt(No), CInt(Zt), CInt(X), CInt(Y))
Do While Hx > 0
    Application.ScreenUpdating = False
    Tetris CInt(No), CInt(Zt), 2, CInt(X), CInt(Y)
    X = X + 1
    Tetris CInt(No), CInt(Zt), CInt(Color), CInt(X), CInt(Y)
    Hx = Minh(CInt(No), CInt(Zt), CInt(X), CInt(Y))
    Application.ScreenUpdating = True
    Sleep Speed
    DoEvents
Loop
kill
For j = 5 To 14
    If Cells(7, j).Interior.ColorIndex <> 2 Then
    MsgBox "GAME OVER!!": Score = Cells(2, 9): tiaozhanbang
    Exit Sub
    End If
Next
GoTo 100
200:
End Sub

[此贴子已经被作者于2023-5-17 10:22编辑过]

搜索更多相关主题的帖子: Sub Int Color Application Case 
2023-05-14 23:37
as9876
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2023-5-11
收藏
得分:0 
又出问题了,还是清高手指点一下
经过vb6论坛大神的指点,改用PeekMessage函数,excel2010能响应按键了,消除时又出现了错误
图片附件: 游客没有浏览图片的权限,请 登录注册

Sub kill()
Score = 1
For i = 23 To 8 Step -1
    For j = 5 To 14
        If Cells(i, j).Interior.ColorIndex = 2 Then
        Exit For
        End If
        If j = 14 Then
            Cells(i, 5).Resize(1, 10).Interior.ColorIndex = 2
            Cells(2, 9) = Cells(2, 9) + 100 * Score
            If Cells(2, 9) > 1000 Then Speed = 200
            For k = i To 8 Step -1
                For l = 5 To 14
                    Cells(k, l).Interior.ColorIndex = Cells(k - 1, l).Interior.ColorIndex
                Next l
            Next k
            i = i + 1
            Score = Score + 1
        End If
    Next j
Next i
End Sub
excel练习-俄罗斯方块5-30.rar (45.69 KB)
2023-06-03 12:38
快速回复:新人求助,俄罗斯方块,求指点,解惑
数据加载中...
 
   



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

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