Sufiyan97
Well-known Member
- Joined
- Apr 12, 2019
- Messages
- 1,538
- Office Version
- 365
- 2013
- Platform
- Windows
I am using below code to play a number shuffle game
How can I reset the count in textbox1?
Below is a code which counts the clicks:
I want a code to number of counts to be zero
How can I reset the count in textbox1?
VBA Code:
Option Explicit
Sub EmptySpotChecker(ByRef Butt1 As CommandButton, ByRef Butt2 As CommandButton)
If Butt2.Caption = "" Then
Butt2.Caption = Butt1.Caption
Butt1.Caption = ""
End If
End Sub
Sub SolutionChecker()
If UserForm.CommandButton1.Caption = "1" And UserForm.CommandButton2.Caption = "2" And UserForm.CommandButton3.Caption = "3" And _
UserForm.CommandButton4.Caption = "4" And UserForm.CommandButton5.Caption = "5" And UserForm.CommandButton6.Caption = "6" And _
UserForm.CommandButton7.Caption = "7" And UserForm.CommandButton8.Caption = "8" And UserForm.CommandButton9.Caption = "9" And _
UserForm.CommandButton10.Caption = "10" And UserForm.CommandButton11.Caption = "11" And UserForm.CommandButton12.Caption = "12" And _
UserForm.CommandButton13.Caption = "13" And UserForm.CommandButton14.Caption = "14" And UserForm.CommandButton15.Caption = "15" Then
Dim a As Integer
a = MsgBox("Well done, you are a Dazzling Star", vbOKOnly, "Xyz Creations")
End If
UserForm.Count = UserForm.Count + 1
UserForm.Caption = "Number of Clicks " & UserForm.Count
UserForm.TextBox1.Text = UserForm.Caption
End Sub
Sub Shuffle()
Dim a(15), i, j, RN As Integer
Dim flag As Boolean
flag = False
i = 1
a(j) = 1
Do While i <= 15
Randomize
RN = CInt(Int((15 * Rnd()) + 1))
For j = 1 To i
If (a(j) = RN) Then
flag = True
Exit For
End If
Next
If flag = True Then
flag = False
Else
a(i) = RN
i = i + 1
End If
Loop
UserForm.CommandButton1.Caption = a(1)
UserForm.CommandButton2.Caption = a(2)
UserForm.CommandButton3.Caption = a(3)
UserForm.CommandButton4.Caption = a(4)
UserForm.CommandButton5.Caption = a(5)
UserForm.CommandButton6.Caption = a(6)
UserForm.CommandButton7.Caption = a(7)
UserForm.CommandButton8.Caption = a(8)
UserForm.CommandButton9.Caption = a(9)
UserForm.CommandButton10.Caption = a(10)
UserForm.CommandButton11.Caption = a(11)
UserForm.CommandButton12.Caption = a(12)
UserForm.CommandButton13.Caption = a(13)
UserForm.CommandButton14.Caption = a(14)
UserForm.CommandButton15.Caption = a(15)
UserForm.CommandButton16.Caption = ""
End Sub
Below is a code which counts the clicks:
I want a code to number of counts to be zero
VBA Code:
UserForm.Count = UserForm.Count + 1
UserForm.Caption = "Number of Clicks " & UserForm.Count
UserForm.TextBox1.Text = UserForm.Caption