VB测试打字速度改进

来源:百度知道 编辑:UC知道 时间:2024/06/06 21:44:11
'通用声明
Dim num As Integer, t0 As Long
Private Sub Command1_Click()
Dim num As Integer, t0 As Long
num = 0
t0 = Timer
Text1.Text = ""
Label2.Caption = 0
Text1.SetFocus

End Sub

Private Sub Command2_Click()
End

End Sub

Private Sub Form_Load()

End Sub

Private Sub Text1_Change()
num = num + 1
Label2.Caption = Int(num * 60 / (Timer - t0))
End Sub

这个是VB设计的 测试打字速度的 现在想做以下改进 希望各位大虾帮帮我啊

1.增加测试已用时间和已录入字符数
2.显示录入即时速度
3.消除退格和删除键的影响

在form中放入2个按钮、1个文本框(设置multiline)、2个timer,3个label(大小都要大一点),粘贴如下代码,运行点command1看效果。

Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim begin, tmp, tmpsec, t1, t2, typet

Private Sub Command1_Click()
Text1 = ""
Text1.SetFocus
begin = GetTickCount
Timer1.Interval = 1000
Timer1.Enabled = True
Timer2.Interval = 200
Timer2.Enabled = True
End Sub
Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Text1 = "准备测试..."
End Sub

Private Sub Text1_Change()
Label1.Caption = "录入字符 " & Len(Text1) & " 个"
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then KeyCode = 0
Text1.SelLength = 0
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then KeyAscii = 0
End Su