Hallo,
Ik ben bezig met Yahtzee te maken in VBA maar krijg het maar niet voor elkaar om de scores automatisch opgeteld te krijgen in de tekstbox. Zou fijn zijn als een van jullie ff kon kijken of ik de code juist heb.
Dim Score As Byte
Dim Teller As Byte
Private Sub CommandButton1_Click()
If Teller < 3 Then
If Me.CheckBox1.Value = False Then
Me.CommandButton6.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton5.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton4.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton3.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton2.Caption = (Int(Rnd * 6) + 1)
End If
Teller = Teller + 1
End If
If Teller > 3 Then Teller = 0
End Sub
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = False Then
Me.CommandButton6.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton5.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton4.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton3.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton2.Caption = (Int(Rnd * 6) + 1)
End If
End Sub
Private Sub Label1_Click()
If CommandButton6 = 1 Then Score = Score + 1
If CommandButton5 = 1 Then Score = Score + 1
If CommandButton4 = 1 Then Score = Score + 1
If CommandButton3 = 1 Then Score = Score + 1
If CommandButton2 = 1 Then Score = Score + 1
Me.TextBox1.Value = Score
Teller = 0
End Sub
Private Sub Label2_Click()
If CommandButton6 = 2 Then Score = Score + 2
If CommandButton5 = 2 Then Score = Score + 2
If CommandButton4 = 2 Then Score = Score + 2
If CommandButton3 = 2 Then Score = Score + 2
If CommandButton2 = 2 Then Score = Score + 2
Me.TextBox2.Value = Score
Teller = 0
End Sub
Private Sub Label3_Click()
If CommandButton6 = 3 Then Score = Score + 3
If CommandButton5 = 3 Then Score = Score + 3
If CommandButton4 = 3 Then Score = Score + 3
If CommandButton3 = 3 Then Score = Score + 3
If CommandButton2 = 3 Then Score = Score + 3
Me.TextBox3.Value = Score
Teller = 0
End Sub
Private Sub Label4_Click()
If CommandButton6 = 4 Then Score = Score + 4
If CommandButton5 = 4 Then Score = Score + 4
If CommandButton4 = 4 Then Score = Score + 4
If CommandButton3 = 4 Then Score = Score + 4
If CommandButton2 = 4 Then Score = Score + 4
Me.TextBox4.Value = Score
Teller = 0
End Sub
Private Sub Label5_Click()
If CommandButton6 = 5 Then Score = Score + 5
If CommandButton5 = 5 Then Score = Score + 5
If CommandButton4 = 5 Then Score = Score + 5
If CommandButton3 = 5 Then Score = Score + 5
If CommandButton2 = 5 Then Score = Score + 5
Me.TextBox5.Value = Score
Teller = 0
End Sub
Private Sub Label6_Click()
If CommandButton6 = 6 Then Score = Score + 6
If CommandButton5 = 6 Then Score = Score + 6
If CommandButton4 = 6 Then Score = Score + 6
If CommandButton3 = 6 Then Score = Score + 6
If CommandButton2 = 6 Then Score = Score + 6
Me.TextBox6.Value = Score
Teller = 0
End Sub
Ik ben bezig met Yahtzee te maken in VBA maar krijg het maar niet voor elkaar om de scores automatisch opgeteld te krijgen in de tekstbox. Zou fijn zijn als een van jullie ff kon kijken of ik de code juist heb.
Dim Score As Byte
Dim Teller As Byte
Private Sub CommandButton1_Click()
If Teller < 3 Then
If Me.CheckBox1.Value = False Then
Me.CommandButton6.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton5.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton4.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton3.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton2.Caption = (Int(Rnd * 6) + 1)
End If
Teller = Teller + 1
End If
If Teller > 3 Then Teller = 0
End Sub
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = False Then
Me.CommandButton6.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton5.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton4.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton3.Caption = (Int(Rnd * 6) + 1)
Me.CommandButton2.Caption = (Int(Rnd * 6) + 1)
End If
End Sub
Private Sub Label1_Click()
If CommandButton6 = 1 Then Score = Score + 1
If CommandButton5 = 1 Then Score = Score + 1
If CommandButton4 = 1 Then Score = Score + 1
If CommandButton3 = 1 Then Score = Score + 1
If CommandButton2 = 1 Then Score = Score + 1
Me.TextBox1.Value = Score
Teller = 0
End Sub
Private Sub Label2_Click()
If CommandButton6 = 2 Then Score = Score + 2
If CommandButton5 = 2 Then Score = Score + 2
If CommandButton4 = 2 Then Score = Score + 2
If CommandButton3 = 2 Then Score = Score + 2
If CommandButton2 = 2 Then Score = Score + 2
Me.TextBox2.Value = Score
Teller = 0
End Sub
Private Sub Label3_Click()
If CommandButton6 = 3 Then Score = Score + 3
If CommandButton5 = 3 Then Score = Score + 3
If CommandButton4 = 3 Then Score = Score + 3
If CommandButton3 = 3 Then Score = Score + 3
If CommandButton2 = 3 Then Score = Score + 3
Me.TextBox3.Value = Score
Teller = 0
End Sub
Private Sub Label4_Click()
If CommandButton6 = 4 Then Score = Score + 4
If CommandButton5 = 4 Then Score = Score + 4
If CommandButton4 = 4 Then Score = Score + 4
If CommandButton3 = 4 Then Score = Score + 4
If CommandButton2 = 4 Then Score = Score + 4
Me.TextBox4.Value = Score
Teller = 0
End Sub
Private Sub Label5_Click()
If CommandButton6 = 5 Then Score = Score + 5
If CommandButton5 = 5 Then Score = Score + 5
If CommandButton4 = 5 Then Score = Score + 5
If CommandButton3 = 5 Then Score = Score + 5
If CommandButton2 = 5 Then Score = Score + 5
Me.TextBox5.Value = Score
Teller = 0
End Sub
Private Sub Label6_Click()
If CommandButton6 = 6 Then Score = Score + 6
If CommandButton5 = 6 Then Score = Score + 6
If CommandButton4 = 6 Then Score = Score + 6
If CommandButton3 = 6 Then Score = Score + 6
If CommandButton2 = 6 Then Score = Score + 6
Me.TextBox6.Value = Score
Teller = 0
End Sub