Solved Access: Form "my Number Puzzle" (See MajP) (1 Viewer)

vhung

Member
Local time
Yesterday, 18:18
Joined
Jul 8, 2020
Messages
235
I love to play the Number Puzzle.
This game is somewhat short term memory and past solving.
It needs quick series thinking.

Ive' done someways to make it possible.
I only use click command through the shuffle numbers, using textbox, 1 to 16.

My look out is how to make it possible using arrows: (up, down, left, right)
I still make research for it.

But for now "my Number Puzzle" already play a game.
 

Attachments

  • AccessNumPuz.png
    AccessNumPuz.png
    80.4 KB · Views: 275

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:18
Joined
May 21, 2018
Messages
8,529
See if this is what you mean
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  '1 2 3 4
  '5 6 7 8
  '9 10 11 12
  '13 14 15 16
  Dim position As Integer
  If KeyCode > 36 And KeyCode < 41 Then
    position = CInt(Mid(ActiveControl.Name, 4))
    'MsgBox position
    Select Case KeyCode
        Case 37 ' move left
          If position <> 1 Then Me.Controls("txt" & position - 1).SetFocus
        Case 38 ' move up
          If position > 4 Then
           Me.Controls("txt" & position - 4).SetFocus
          Else
           Me.Controls("txt" & position + 12).SetFocus
          End If
        Case 39
          If position <> 16 Then Me.Controls("txt" & position + 1).SetFocus
        Case 40 ' move down
          If position < 13 Then
            Me.Controls("txt" & position + 4).SetFocus
          Else
            Me.Controls("txt" & position - 12).SetFocus
          End If
    End Select
  End If
End Sub
 

Attachments

  • Database1.accdb
    380 KB · Views: 157

vhung

Member
Local time
Yesterday, 18:18
Joined
Jul 8, 2020
Messages
235
See if this is what you mean
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  '1 2 3 4
  '5 6 7 8
  '9 10 11 12
  '13 14 15 16
  Dim position As Integer
  If KeyCode > 36 And KeyCode < 41 Then
    position = CInt(Mid(ActiveControl.Name, 4))
    'MsgBox position
    Select Case KeyCode
        Case 37 ' move left
          If position <> 1 Then Me.Controls("txt" & position - 1).SetFocus
        Case 38 ' move up
          If position > 4 Then
           Me.Controls("txt" & position - 4).SetFocus
          Else
           Me.Controls("txt" & position + 12).SetFocus
          End If
        Case 39
          If position <> 16 Then Me.Controls("txt" & position + 1).SetFocus
        Case 40 ' move down
          If position < 13 Then
            Me.Controls("txt" & position + 4).SetFocus
          Else
            Me.Controls("txt" & position - 12).SetFocus
          End If
    End Select
  End If
End Sub
[/QUOTE]
Nice; i'll try this code; Thanks MajP
 

vhung

Member
Local time
Yesterday, 18:18
Joined
Jul 8, 2020
Messages
235
MajP, post:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Wow it works, i'm done.
Thank you very much.
 

Attachments

  • AccessNumPuz.png
    AccessNumPuz.png
    83.3 KB · Views: 275
Last edited:

Users who are viewing this thread

Top Bottom