Why does not the DoEvents record the keys correctly? VBA

0

my code is this:

Public x As Integer
Public y As Integer
Public ax As Integer
Public ay As Integer
Public xpie(3) As Integer
Public ypie(3) As Integer
'funciones
Function selectxy(x, y)
 selectxy = Cells(y, x)
End Function
'metodos
Sub inOpen()
 With Range("a1", "t20")
  .Interior.Color = RGB(255, 255, 255)
  .RowHeight = 13
  .ColumnWidth = 2

 End With
 For Each xp In xpie
  xp = Rnd(100)
 Next xp
 Debug.Print ("empieza")
 'teclas
 Application.OnKey "{RIGHT}", "right"
 Application.OnKey "{LEFT}", "left"
 'inisialisacion
 x = 1
 y = 20
 Cells(y, x).Interior.Color = RGB(0, 0, 255)

End Sub
Sub right()
 If x <> 20 Then
 ax = x
 x = x + 1
 Cells(y, x).Interior.Color = RGB(0, 0, 255)
 Cells(y, ax).Interior.Color = RGB(255, 255, 255)
 End If
End Sub
Sub left()
 If x <> 1 Then
 ax = x
 x = x - 1
 Cells(y, x).Interior.Color = RGB(0, 0, 255)
 Cells(y, ax).Interior.Color = RGB(255, 255, 255)
 End If
End Sub
Sub game()
 Do

 DoEvents
 Cells(y, x).Interior.Color = RGB(0, 0, 100)
 DoEvents
 Loop While True
End Sub
    
asked by miguel 07.03.2018 в 23:22
source

0 answers