Dim m, s As Double
Private Sub Command1_Click()
Text2.Text = ""
Text1.Text = ""
For i = 1 To 30
Text2.Text = Text2.Text & Chr(Int(Rnd * 25 + 66))
Next i
Timer1.Enabled = True
Timer1.Interval = 1000
m = 0
s = 1
End Sub
Private Sub Command2_Click()
Dim b As Integer
For i = 1 To 30
If Mid(Text1.Text, i, 1) = Mid(Text2.Text, i, 1) Then b = b + 1
Next i
Text3.Text = Int(b / 30 * 100) & "%"
Timer1.Enabled = False
Timer1.Interval = 0
Text4.Text = m & "分" & s & "秒"
End Sub
Private Sub Form_Load()
Text3.Text = ""
Text4.Text = ""
Text2.Text = ""
Text1.Text = ""
For i = 1 To 30
Text2.Text = Text2.Text & Chr(Int(Rnd * 25 + 66))
Next i
Command1.Caption = "重新生成"
Command2.Caption = "计算"
Label1.Caption = "准确率"
Label2.Caption = "用时"
Text1.Locked = True
Text1.MaxLength = 30
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 And Len(Text1.Text) >= 1 Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
If KeyAscii > 64 And KeyAscii < 91 Then Text1.Text = Text1.Text & Chr(KeyAscii)
If KeyAscii > 96 And KeyAscii < 123 Then Text1.Text = Text1.Text & Chr(KeyAscii - 32)
End Sub
Private Sub Timer1_Timer()
If s > 60 Then s = 0: m = m + 1
s = s + 1
End Sub
呃,没看到图。