Dim i As Integer '
Dim zheng As Integer '保存输入正确的值
Dim err1 As Integer '保存输入错误的值
Dim timei As Integer
Private Sub Command1_Click()
Dim name As String
With CommonDialog1
.ShowOpen
name = .FileName
End With
RichTextBox1.LoadFile name
ccrpProgressBar1.Max = Len(RichTextBox1.Text)
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
End Sub
Private Sub Form_Load()
ccrpProgressBar1.Max = Len(RichTextBox1.Text)
i = 1
timei = 0
RichTextBox1.SelStart = 3
RichTextBox1.SelColor = vbRed
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) <> 0 Then
If Mid(RichTextBox1.Text, Len(Text1.Text), 1) = Mid(Text1.Text, Len(Text1.Text), 1) Then
RichTextBox1.SelStart = i - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = vbBlue
zheng = zheng + 1
i = i + 1
Else
If i = -1 Then
i = 1
End If
RichTextBox1.SelStart = i - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = vbRed
i = i + 1
err1 = err1 + 1
End If
Else
i = i - 1
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = &H80000012
End If
If ccrpProgressBar1.Value >= Len(Text1.Text) Then
MsgBox "ok"
Exit Sub
Else
ccrpProgressBar1.Value = Len(Text1.Text)
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim rlen As Integer '保存RText的值
Dim tlen As Integer '保存text1的值
If KeyAscii = 8 Then
rlen = Len(RichTextBox1.Text)
tlen = Len(Text1.Text)
If tlen > 1 Then
RichTextBox1.SelStart = tlen - 1
RichTextBox1.SelLength = rlen
RichTextBox1.SelColor = &H80000012
i = i - 2
End If
End If
If ccrpProgressBar1.Value <> 0 Then
ccrpProgressBar1.Value = ccrpProgressBar1.Value - 1
End If
End Sub
Private Sub Timer1_Timer()
timei = timei + 1
Label2.Caption = Int(((Len(Text1.Text)) / timei) * 60) & "/分"
End Sub
'by dz
建议用 明天打字员 这个比较好用。
VB代码是这么练习的么 `?