Code pour creer le jeu de la vie avec excel

844 mots 4 pages
GAME OF LIFE EXCEL VBA CODE:

Code with the worksheet where the code will be run
Private Sub CmdClearGrid_Click() Call ClearGrid
End Sub

Private Sub CmdFillGrid_Click() Call FillGridLine
End Sub

Private Sub CmdStart_Click() Me.TxtNumberOfGenerations.Enabled = False If Me.TxtNumberOfGenerations.Text = "" Then Me.TxtNumberOfGenerations.Text = "0" Call GridLineGameOfLife
End Sub

Private Sub CommandButton1_Click() StopGame = True
End Sub

Private Sub TxtNumberOfGenerations_Change() End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range) If StopSelectionChange = True Then Exit Sub If Intersect(ActiveCell, Range("B2", Cells(MaxValue + 1, MaxValue + 1))) Is Nothing Then 'no action Else If Target.Interior.Color = 0 Then Target.Interior.Color = 16777215 Else Target.Interior.Color = 0 End If End If Cells(1, 1).Select
End Sub

Fill_gridline module
Dim i As Integer
Sub FillGridLine() StopSelectionChange = True Dim RandomValue As Byte Application.ScreenUpdating = False For i = 0 To MaxValue2 - MaxValue RandomValue = Int(Rnd * 2) Select Case RandomValue Case Is = 0 Cells(ConvertNbrRow(i), ConvertNbrColumn(i)).Interior.Color = 0 Case Is = 1 Cells(ConvertNbrRow(i), ConvertNbrColumn(i)).Interior.Color = 16777215 End Select Next i Application.ScreenUpdating = True StopSelectionChange = False

End Sub

Sub ClearGrid() StopSelectionChange = True For i = 0 To MaxValue2 Cells(ConvertNbrRow(i), ConvertNbrColumn(i)).Interior.Color = 16777215 Cells(ConvertNbrRow(i), ConvertNbrColumn(i)).Select Next i StopSelectionChange = False ProjectGridOfLife.Sheet2.LblNumberOfGenerations.Caption = ""
End Sub

Gridline
Option Explicit
Option Base 1
Global StopSelectionChange As Boolean
Public Const MaxValue As Integer = 50
Public Const MaxValue2 As Integer = MaxValue ^ 2 - 1
Dim GridRow As Integer, GridCol As Integer, NeighborCell As Integer
Dim ColCell As

en relation

  • corrigé livre de maths terminale sti2d/ stl édition Nathan technique chapitre statistiques à 2 variables
    1885 mots | 8 pages
  • Corrigé dm de math
    612 mots | 3 pages
  • Les Listes PSI
    808 mots | 4 pages
  • Étude de la réaction de hill dans une feuille d'épinard
    992 mots | 4 pages
  • Fonctions Graph35
    1425 mots | 6 pages
  • inf1250 -tp2
    1393 mots | 6 pages
  • Questionnaire parrot
    4726 mots | 19 pages
  • R Sultat Fast Surf
    4367 mots | 18 pages
  • L'accélération
    394 mots | 2 pages
  • Transmissions réseaux
    1300 mots | 6 pages
  • Log in 6
    2112 mots | 9 pages
  • analyse de situation éthique
    2717 mots | 11 pages
  • Resolution d`un programme lineaire
    255 mots | 2 pages
  • Librairie effets javascript
    469 mots | 2 pages
  • Htmlcss
    1017 mots | 5 pages