Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s As String Dim i, j As Integer Dim n(14, 14) As Integer n = evolution(celltab) celltab = n For i = 0 To 14 For j = 0 To 14 If celltab(i, j) = 0 Then s &= " " & optcvide ElseIf celltab(i, j) = 0 Then s &= " " & optccell End If Next s &= vbCrLf Next TextBox1.Text = s TextBox1.BackColor = bgcolor TextBox1.ForeColor = charcolor
Public Function evolution(ByVal oldtab(,) As Integer) As Integer(,) Dim newtab(14, 14) As Integer Dim i, j As Integer 'initialisation de la nouvelle grille de cellules avec des cellules neutre(vide) For i = 0 To 14 For j = 0 To 14 newtab(i, j) = 0 Next Next For i = 1 To 13 For j = 1 To 13 If oldtab(i, j) = 1 Then newtab(i - 1, j - 1) += 1 newtab(i - 1, j) += 1 newtab(i - 1, j + 1) += 1 newtab(i, j - 1) += 1 newtab(i, j + 1) += 1 newtab(i + 1, j - 1) += 1 newtab(i + 1, j) += 1 newtab(i + 1, j + 1) += 1 End If Next Next 'verification du nombres de voisins direct aux cellules de la grille en parametre For i = 1 To 13 For j = 1 To 13 If oldtab(i, j) = 1 Then If newtab(i, j) = 2 Then newtab(i, j) = 1 Exit For ElseIf newtab(i, j) = 3 Then newtab(i, j) = 1 Exit For Else newtab(i, j) = 0 Exit For End If ElseIf oldtab(i, j) = 0 Then If newtab(i, j) = 3 Then newtab(i, j) = 1 Exit For Else newtab(i, j) = 0 Exit For End If End If Next Next Return newtab End Function