icemail
06-17-2016, 06:51 AM
hi
im making little game. about skills and hotkeys. Picture coming and press short keys.
create userform1
start and textbox
press start button timer is starting
and findin a key
after questin for loop how many times press a key(5-10-15-20-50-100 whatever)
and there is my questin. i dont trigger for loop. key is always same not change :(
pls help me
thx
my codes
Dim n As Integer
Dim shortkeys As Variant
Dim correct, incorrect, sum As String
Dim StartTime As Double
Dim val As String
Private Sub CommandButton1_Click()
StartTime = Timer
Call keys
End Sub
Sub keys()
shortkeys = Array("m", "a", "g", "b", "h", "p", "y", "o", "s", "g", "r", "u", "l", "u", "u", "d", "e", "c", "f", "d", "f", "k", "p", "f", "h", "d", "m", "f", "p", "c", "w", "r", "s", "w", "o", "i", "b", "t", "c", "e", "g", "g", "s", "s", "s", "g", "g", "g", "p", "p", "p", "a", "a", "a", "m", "m", "m", "b", "l", "l", "d", "a", "t", "t", "t", "t", "l", "m", "r", "h", "g", "b", "c", "s", "c", "a", "w", "r", "b", "s", "u", "f", "g", "c", "g", "t", "n", "r", "v", "l", "u", "b", "n", "f", "b", "x", "a", "b", "w", "r", "t", "m", "t", "c", "b", "v", "l", "t", "d", "v", "r")
n = Application.WorksheetFunction.RandBetween(LBound(shortkeys), UBound(shortkeys))
'Show keys
Label7.Caption = shortkeys(n)
val = InputBox("Enter repeat number")
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
For i = 1 To val
If TextBox1.Text = shortkeys(n) Then
correct = correct + 1
Else
incorrect = incorrect + 1
End If
TextBox1.Text = ""
sum = correct + incorrect
percentage = correct / sum
Label6.Caption = Format(percentage, "Percent")
Label4.Caption = correct
Label1.Caption = Format((Timer - StartTime) / 86400, "hh:mm:ss")
Next i
End Sub
im making little game. about skills and hotkeys. Picture coming and press short keys.
create userform1
start and textbox
press start button timer is starting
and findin a key
after questin for loop how many times press a key(5-10-15-20-50-100 whatever)
and there is my questin. i dont trigger for loop. key is always same not change :(
pls help me
thx
my codes
Dim n As Integer
Dim shortkeys As Variant
Dim correct, incorrect, sum As String
Dim StartTime As Double
Dim val As String
Private Sub CommandButton1_Click()
StartTime = Timer
Call keys
End Sub
Sub keys()
shortkeys = Array("m", "a", "g", "b", "h", "p", "y", "o", "s", "g", "r", "u", "l", "u", "u", "d", "e", "c", "f", "d", "f", "k", "p", "f", "h", "d", "m", "f", "p", "c", "w", "r", "s", "w", "o", "i", "b", "t", "c", "e", "g", "g", "s", "s", "s", "g", "g", "g", "p", "p", "p", "a", "a", "a", "m", "m", "m", "b", "l", "l", "d", "a", "t", "t", "t", "t", "l", "m", "r", "h", "g", "b", "c", "s", "c", "a", "w", "r", "b", "s", "u", "f", "g", "c", "g", "t", "n", "r", "v", "l", "u", "b", "n", "f", "b", "x", "a", "b", "w", "r", "t", "m", "t", "c", "b", "v", "l", "t", "d", "v", "r")
n = Application.WorksheetFunction.RandBetween(LBound(shortkeys), UBound(shortkeys))
'Show keys
Label7.Caption = shortkeys(n)
val = InputBox("Enter repeat number")
End Sub
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
For i = 1 To val
If TextBox1.Text = shortkeys(n) Then
correct = correct + 1
Else
incorrect = incorrect + 1
End If
TextBox1.Text = ""
sum = correct + incorrect
percentage = correct / sum
Label6.Caption = Format(percentage, "Percent")
Label4.Caption = correct
Label1.Caption = Format((Timer - StartTime) / 86400, "hh:mm:ss")
Next i
End Sub