I would like to thank once more!!!! What I am doing is much more complicated. I have a button A in which a picture of 1 Euro is displayed after of an average 70 clicks. Simultaneously there is a timer which functions randomly from 1 sec to 35 sec andmay steal this euro and then another picture is displayed showing a euro with an X. I wanted the code with the timers so I could keep track of the clicks and the time, so as to can calculate the frequency per minute. The button B has a timer, which postpones the loss for 45 sec, after having pressed for 10 times. The person does not click this button with the mouse. Instead, presses the letter K from the keyboard. (Here, the problem that I have faced is that hecan press the letter more than 10 times, so the timer that you suggested me, keeps counting -
so I would like the presses of the letter K to be deactivated after the 10 presses). The code is the following (Just because you asked me - Hope not to disturbing you with all my silly questions)
Private
Sub butA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butA.Click
SW.Start()
vClicksB = 0
lblTime.Text = VB.Timer - vTime
vTime1 = VB.Timer
butB.Visible =
False
vCount = vCount + 1
If (Me.BackColor = Color.Salmon) AndAlso (tmrCheck.Enabled = False) AndAlso VB.Timer - vTime > vRand Then
imgB.Visible =
True
butA.Visible =
False
butB.Visible =
False
vCount = 0
vClicks = -1
rand_number()
randA_number()
lblNoPoints.Text = vPoints + 1
lblPoints.Text = lblPoints.Text - 1
vPoints = vPoints + 1
SW.Stop()
End If
vClicks = vClicks + 1
vSumA = vSumA + 1
If vClicks >= vRandA Then
imgA.Visible =
True
butA.Visible =
False
butB.Visible =
False
randA_number()
vClicks = 0
vCount = 0
rand_number()
lblPoints.Text = lblPoints.Text + 1
SW.Stop()
End If
If (tmrCheck.Enabled = True) AndAlso (vClicks >= vRandA) Then
imgA.Visible =
True
butA.Visible =
False
butB.Visible =
False
vClicks = 0
randA_number()
vCount = 0
rand_number()
lblPoints.Text = lblPoints.Text + 1
SW.Stop()
End If
lblTotPoints.Text = (lblPoints.Text) - (lblNoPoints.Text)
If SW.ElapsedMilliseconds > 60000 Then
SW.Reset()
vSumA = 0 ' this code is the code I asked for so I could calculate the frequecy afrewards
End If
Label1.Text =
CStr(SW.ElapsedMilliseconds / 1000)
WriteLine(6, vRand, vRandA, vClicks, vCount, lblTime.Text, lblPoints.Text, lblNoPoints.Text, lblTotPoints.Text,
Me.BackColor = Color.SkyBlue, Me.BackColor = Color.Salmon, Me.BackColor = Color.LightSalmon, Label1.Text, vSumA)
End Sub
Private
Sub Form9_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.K
butB_Click(sender,
New System.EventArgs)
End Select
End Sub
Private Sub butB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butB.Click
SW2.Start()
lblTime.Text = VB.Timer - vTime
vTime1 = VB.Timer
vClicksB = vClicksB + 1
vSumB = vSumB + 1
butA.Visible =
False
tmrCheck.Enabled =
False
If (vClicks = 0) AndAlso (vClicksB > 9) Then
imgC.Visible =
True
butA.Visible =
False
butB.Visible =
False
Me.BackColor = Color.SkyBlue
vClicksB = 0
vCount = 0
rand_number()
SW2.Stop()
End If
if SW2.ElapsedMIlliseconds > 30000 then
SW2.Reset ()
End if
Label2.Text = CInt(SW2.ElapsedMilliseconds)
WriteLine(6,
"The button B was pushed" & " ", vClicksB, lblTime.Text, "The safety period was" & " ", tmrCheck.Interval, Me.BackColor = Color.SkyBlue, Me.BackColor = Color.Salmon, Me.BackColor = Color.LightSalmon, Label2.Text / 1000, vSumB)
End Sub