📄 frmtest.frm
字号:
VERSION 5.00
Begin VB.Form frmtest
BorderStyle = 3 'Fixed Dialog
ClientHeight = 3630
ClientLeft = 45
ClientTop = 330
ClientWidth = 3690
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 3630
ScaleWidth = 3690
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Left = 3240
Top = 2760
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 2415
Left = 120
MultiLine = -1 'True
TabIndex = 1
Top = 240
Width = 3375
End
Begin VB.CommandButton cmdExit
Caption = "Exit"
Height = 375
Left = 2400
TabIndex = 3
Top = 2760
Width = 735
End
Begin VB.CommandButton cmdStop
Caption = "Stop"
Height = 375
Left = 1440
TabIndex = 2
Top = 2760
Width = 735
End
Begin VB.CommandButton cmdStart
Caption = "Start"
Height = 375
Left = 480
TabIndex = 0
Top = 2760
Width = 735
End
Begin VB.Label Label1
Caption = "2:00"
ForeColor = &H0000FFFF&
Height = 255
Left = 3000
TabIndex = 4
Top = 0
Width = 615
End
End
Attribute VB_Name = "frmtest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim starting As Boolean, FIRST_OVER As Boolean
Dim examx As Integer
Dim examy As Integer
Dim time_count As Integer
Dim total_words As Integer, words_typed As Integer
Dim keystrokes As Integer
Dim typed_text1 As String, typed_text2 As String
Dim temp As String
Private Sub cmdExit_Click()
Unload Me
frmMain.Show
End Sub
'This is for start the timer when the start button clicked
Private Sub cmdStart_Click()
On Error Resume Next
time_count = 120
Text1.text = ""
Text1.SetFocus
cmdStop.Enabled = True
If (starting = False) Then
Timer1.Enabled = True
starting = True
End If
End Sub
'This is for stop the timer when the stop button clicked
Private Sub cmdStop_Click()
Timer1.Enabled = False
Call display_result
Text1.text = ""
Label1.Caption = "2:00"
starting = False
keystrokes = 0
End Sub
'this is for load the form
Private Sub Form_Load()
FIRST_OVER = False
time_count = 120
Text1.text = " "
Timer1.Interval = 1000
Timer1.Enabled = False
Text1.SelStart = 4
starting = False
cmdStop.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Show
End Sub
Private Sub Text1_Change()
keystrokes = keystrokes + 1
End Sub
Private Sub Timer1_Timer()
If (time_count > 0) Then
time_count = time_count - 1
Label1.Caption = str(time_count \ 60) + " : " + str(time_count Mod 60)
Else
'Call display_result
Call cmdStop_Click
End If
End Sub
'This procedure is used for display the results such as words_per_min,no_of_keystokes,Keys / minute
Sub display_result()
Dim keys_per_min As Double
Dim words_per_min As Double
Dim minutes As Integer
Dim time_ratio As Double
temp = ""
Timer1.Enabled = False
time_ratio = (120 - time_count) / 60
typed_text1 = Text1.text
words_typed = words_count(typed_text1)
If (typed_text1 = "") Then
time_ratio = 1
End If
words_per_min = words_typed / time_ratio
words_per_min = words_per_min \ 1
keys_per_min = keystrokes / time_ratio
keys_per_min = keys_per_min \ 1
temp = temp + "Time allowted : 2 min" + vbNewLine
temp = temp + "Words typed : " + str(words_typed) + vbNewLine
temp = temp + "Words / minute : " + str(words_per_min) + vbNewLine
temp = temp + "Key strokes : " + str(keystrokes) + vbNewLine
temp = temp + "Keys / minute : " + str(keys_per_min) + vbNewLine
MsgBox temp
Text1.text = ""
cmdStop.Enabled = False
End Sub
'this function is used for calculate the no of words
Function words_count(str As String) As Integer
words_count = 0
Dim space_pos As Integer
Dim text As String
text = str
text = LTrim(text)
text = RTrim(text)
Do
text = Mid(text, space_pos + 1, Len(text) - co)
text = LTrim(text)
space_pos = InStr(1, text, " ", vbTextCompare)
words_count = words_count + 1
Loop While (space_pos <> 0)
If (Len(str) < 1) Then
words_count = 0
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -