AccessSweeper: Uncover the Fun!

murray83

Games Collector
Local time
Today, 00:18
Joined
Mar 31, 2017
Messages
840
AccessSweeper: Uncover the Fun!


Back again, making DB's not dull and boring. My target this time was Minesweeper so please...

Dive into the captivating world of AccessSweeper, the ultimate twist on the classic Minesweeper game, now designed for Microsoft Access! Challenge your mind and reflexes as you navigate through a grid filled with hidden treasures and potential pitfalls.

Game Features:

  • Three Exciting Levels: Choose your challenge with Easy, Medium, and Hard modes, each offering a unique grid size and complexity to keep you engaged.
  • Intuitive Gameplay: Use your mouse to click and reveal tiles, uncovering numbers that indicate the proximity of hidden mines. Strategically deduce safe spots and avoid explosive surprises!
  • User-Friendly Interface: Designed with accessibility in mind, AccessSweeper is easy to navigate, making it perfect for players of all ages and skill levels.
Get ready to think critically, strategize, and have a blast with AccessSweeper! Will you uncover the secrets of the grid, or will you fall victim to the mines? The adventure awaits!

FYI there is a counter and an end goal but as yet not capturing anything

enjoy and as always welcome to feedback good and bad

:)
 

Attachments

It does

What you mean ?
 
1750610619940.png
 
Looking at your code a bit more: I bet you were getting tired of flawlessly writing the 100 MouseDown events.
There is a better way: control subclassing. The modified version is attached.
 

Attachments

Last edited:
first time seen that issue crop up and in regard to the mouse down yeah but then i just had duckduckgo AI chat repeat them for txt_5_n so on on up to the txt_10_n

and ill check yours out, cheers
The benefit of Tom's method, is if you have to update the events, you do it once in the class, not as many times as you have textboxes.
I am a little confused as to why you use loops in some places and hardcode in others?

@tvanstiphout I was trying to do something like you have done in another thread, but got lost on the collection code.
Why is there no collection for your class, despite multiple controls? :unsure:
 
I was trying to do something like you have done in another thread, but got lost on the collection code.
Why is there no collection for your class, despite multiple controls?
IMO if you really may want a collection class when you need to do a lot of management of all the objects or you want the class to raise events and you trap the events. That is a more work but gives you more flexibility. Probably overkill here.

I describe that here.

This way you can make the class more agnostic and decoupled. You do not put the processing of the form in the class and your not referencing the properties of the parent form. You are simply trapping events and then having a centralized mean to echo these events.

In @tvanstiphout class only works with a specific parent form with specific properties and events procedures. So this works well and is quick and easy. But it is tightly coupled and not very flexible to be used universally. It works with this form but could not be used with all forms that you want to manage the mouse down event. Here you see the need to couple to the parent form.
Code:
If Button = 2 Then ' Right mouse button
        m_txt.Parent.ToggleFlag m_intRow, m_intCol
    Else
        m_txt.Parent.txtCell_Click ' Call the existing click event for left-click
    End If

If I wanted to make it more universal I would add all my objects to my custom collection class, and have the collection class raise a custom event when any of the objects receive a mouse down. Then the custom event can echo the txt box object, button, shift x, y. Now any form can process that single event and use the custom collection class as the universal "messenger". But again probably overkill for this.
 
Yes, mine was doing the same thing, purely for that example to reduce all those individual click events.
That was all I was trying to accomplish.
Code:
Option Compare Database
Option Explicit
'
Private WithEvents mCmd As CommandButton
Private Const mcstrEvProc As String = "[Event Procedure]"
'
Private Const cstrAlphabet As String = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ"

Public Function Init(lCmd As CommandButton, iAlpha As Integer)
    Set mCmd = lCmd
    mCmd.Caption = Mid(cstrAlphabet, iAlpha, 1)
    mCmd.OnClick = mcstrEvProc
End Function

Private Sub Class_Terminate()
    Set mCmd = Nothing
End Sub
Private Sub mCmd_Click()
    LocateRecord (mCmd.Caption)
End Sub

Private Sub LocateRecord(strCaption As String)
    Dim i As Integer, strAin As String
    'Debug.Print Screen.ActiveControl.ControlType
    
    DoCmd.RunCommand acCmdSaveRecord
    mCmd.Parent.RecordsetClone.FindFirst "[AAC] = '" & strCaption & "'"
    mCmd.Parent.Bookmark = mCmd.Parent.RecordsetClone.Bookmark
    strAin = mCmd.Parent.RecordsetClone.Fields("AIN")
    
    mCmd.Parent.NavMenu = mCmd.Parent.NavMenu.ItemData(strAin) 'RecordsetClone![AIN]
    'Debug.Print strCaption & " - " & mCmd.Parent.NavMenu.ItemData(strAin) & " - " & strAin

End Sub
 
I see. Although @tvanstiphout does not use a collection they use an array to hold all of the instances. Basically the same thing. You have to hold them with something. Array, regular collection, or a collection class (which has a collection built in)

Dim m_txt(99) As clsTextbox ' uses an array to hold the instances

However, what I see people try do is just make a single class variable.

Private m_Txt as clsTexbox

Then in some event they loop the controls and set each one to m_Txt. That ends up just creating a single instances since each time you are overwriting the single variable. Whatever control is looped last gets intialized as m_txt

So if you are building command button class for all the command buttons on that form then at the top of the form you will need something to store your instances.

Private NewCmd as ClsGasmandCommand '
Private MyCommands as new Collection ' a collection to hold all your instances

loop the comand buttons in the form and do something


Code:
For Each Ctrl in me.controls
  if ctrl.controlType = acCommandButton then
     Set NewCmd = new ClsGasmanCommandButton  'create an instance
     NewCmd.initialize me.controls ctrl,ctrl.tag
     mycommands.add ctrl, ctrl.tag
  end if
next

There is a trick that you can do so that you can just have a single instance and not an array or collection to hold them. You initialize it prior to using it for the active control


private GasmanButton as ClsGasmanCommandButton

Then you could have a function property on each command buttons click event

Code:
Private Function SomethingClicked
  set GasmanButton = New clsGasmanCommandButton
  GasmanButton.init ActiveControl, ActiveControl.tag
end Function
 

Users who are viewing this thread

Back
Top Bottom