Conway Game Of Life implemented

rogster001

New Member
Joined
Jun 17, 2010
Messages
45
Hi all,

I have been playing around with some little VBA projects by way of learning the language, to give me something to focus on i have implemented a couple of things that are traditional programming projects like the Conway Game of Life which i have done in other languages.

It is most amusing seeing excel doing things like this, and i am learning a lot.

The program works perfectly as a alt+f8 macro call, colouring in the cells according to the algorithm, looks rather cool too.

The problem i am having is keeping the interface responsive while the program runs, i need a 'check' function that looks for any events periodically, to prevent the gui hanging.
I read about the application.DoEvents function, but i get an error saying object property is not defined... i beleive this as it was not in the list of available properties that appeared in the popupbox, yet it still compiled. i imagiune this is because i am using it in the wrong place? or type?

Here is the code snippet:

Code:
Sub GameOfLife()
 
    SetupWorld
    For j = 1 To 100               'number of generations
       UpdateWorld                 ' the algorithm, scans 50x50 cells grid and 
                                          'populates acccording to algorithm        
       Application.DoEvents       'I would like to check for events here.
    Next j
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
ok thanks, will give it a go now, the other thing is say i get the event checking working, then i would want to be able to stop the main loop, could i do this by changing a boolean value say that controls a while loop? is there a while loop or similar available... i imagine there must be...
 
Upvote 0
Ok nice one, it all works ok now, One thing though is that i would like the user to be able to manually define the starting cell configuration if so desired. At present they can choose from a number of library presets via form buttons, the 'user define' button is implemented but i cannot give control to the sheet without hiding the userform, is there any way of keeping the form visible (and with buttons enabled) and allowing the user to interact with the worksheet at the same time, so they can return to the form when ready and hit 'start'

I thought of a workaround as "user hits 'userdefine' button on form
form closes
user inputs starting cells on the worksheet
user hits a cell 'DONE' that has a macro assigned to reopen the form
user hits startbutton on form
algorithm begins

Is this the only way to do it? within reason?
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top