- 4,801
- 1,233
- CPU
- i5 2500k+EK 240 LTX/ AthlonII x2 255 + CM Hyper 212+
- Scheda Madre
- GIGABYTE P67A-UD4-B3/asrock A770DE+
- HDD
- Crucial m4 64GB/WD Caviar Black 500Gb /Seagate Barracuda 750GB / maxtor 500 gb
- RAM
- XMS3 12 GB DDR3-1600Mhz Cl9/Kingston hyperx DDR2 cl7 1066MHz 2x2GB
- GPU
- GTX1080 MSI Armor OC / 7970 Lightning @1200 / Sapphire HD5770
- PSU
- Hx850 Corsair / Vx450 corsair
- Case
- Corsair 600T White
- OS
- win 10
salve a tutti ragazzi , a scuola abbiamo fatto il gioco della vita
Gioco Life di Conway - Wikipedia
ora il professore mi ha chiesto di fare un do while loop che esegua in automatico quello che io invece vado a fare cliccando piu volte sullo stesso bottone , cliccandoci 1 sola volta !
in sostanza il loop dove dovrei metterlo?
( fatto in vba )
Private Sub SECONDAGENERAZIONE_Click()
variabile--->fl = 1
Do While fl = 1
For r = 4 To 11
For c = 4 To 11
cont = 0
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = 1 Then
If cont = 2 Or cont = 3 Then
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 1
Else
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 0
End If
Else
If cont = 3 Then
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 1
Else
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 0
End If
End If
Next c
Next r
For r = 4 To 11
For c = 4 To 11
Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c)
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = 1 Then
Cells(r, c).Interior.Color = RGB(228, 121, 4)
Cells(r, c).Characters.Font.Color = RGB(228, 121, 4)
Else
Cells(r, c).Interior.Color = RGB(0, 0, 0)
Cells(r, c).Characters.Font.Color = RGB(0, 0, 0)
End If
Next
Next
End Sub
Gioco Life di Conway - Wikipedia
ora il professore mi ha chiesto di fare un do while loop che esegua in automatico quello che io invece vado a fare cliccando piu volte sullo stesso bottone , cliccandoci 1 sola volta !
in sostanza il loop dove dovrei metterlo?
( fatto in vba )
Private Sub SECONDAGENERAZIONE_Click()
variabile--->fl = 1
Do While fl = 1
For r = 4 To 11
For c = 4 To 11
cont = 0
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c - 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c - 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r - 1, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r + 1, c) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c + 1) = 1 And _
Workbooks(1).Worksheets("Gioco vita").Cells(r, c + 1) <> "" Then
cont = cont + 1
End If
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = 1 Then
If cont = 2 Or cont = 3 Then
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 1
Else
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 0
End If
Else
If cont = 3 Then
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 1
Else
Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c) = 0
End If
End If
Next c
Next r
For r = 4 To 11
For c = 4 To 11
Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = Workbooks(1).Worksheets("Gioco vita").Cells(r + 75, c)
If Workbooks(1).Worksheets("Gioco vita").Cells(r, c) = 1 Then
Cells(r, c).Interior.Color = RGB(228, 121, 4)
Cells(r, c).Characters.Font.Color = RGB(228, 121, 4)
Else
Cells(r, c).Interior.Color = RGB(0, 0, 0)
Cells(r, c).Characters.Font.Color = RGB(0, 0, 0)
End If
Next
Next
End Sub