主题:文件操作为什么老出错,导入内容不对
代码:
Dim x(4) As String * 104
Dim StartTime As String
Dim t1 As Long
Dim sum As Long
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
StartTime = Time
Call Import
Lspeed.Caption = "0 WPM"
End Sub
Private Sub Text1_Change(index As Integer)
Dim sub1, sub2 As String '定义 存放字符串的变量sub1和 sub2
Dim plong As Integer '定义存放picture中字符串长度的变量
Dim count As Long
count = 0: sum = 0
For k = 0 To 4
plong = 100 '将picture中字符串的长度存入plong
len1 = Len(Text1(k).Text) '将text中输入的字符串长度存入len1
For i = 1 To len1
sub1 = Mid(Text1(k), i, 1) '从text中i位置开始取一个字符
sub2 = Mid(x(k), i, 1) '从picture中从i开始取一个字符
count = count + 1: sum = sum + 1
If sub1 <> sub2 Then '当text中输入的字符和picture中的不一样的时候,将picture中的该字符重新打印并显示为红色
p1(k).ForeColor = vbRed '设置picture的前景色为红色
p1(k).CurrentY = 10 '定位x的当前位置
p1(k).CurrentX = (i - 1) * 8 '定位x的当前位置
p1(k).Print sub2 '将输错的字符在picture中用红色重新打印
count = count - 1
End If
If plong = len1 Then '一行输完后的处理
If k + 1 <= 4 Then
Text1(k + 1).SetFocus
plong = 0: len1 = 0
Else
p1(k).Cls
Text1(k) = ""
End If
End If
Next i
plong = 0: len1 = 0
Next k
Lright.Caption = Format((count / sum) * 100, "0.00") & "%"
End Sub
Private Sub Import()
For i = 0 To 4
Open App.Path + "\english.txt" For Input As #1
Line Input #1, x(i)
p1(i).CurrentY = 10
p1(i).Print x(i)
Close #1
Next i
End Sub
Private Sub Timer1_Timer()
Dim intS As Long
intS = Val(DateDiff("s", StartTime, Time))
Ltime.Caption = Format(intS \ 3600, "00") & ":" & Format((intS Mod 3600) \ 60, "00") & ":" & Format(intS Mod 60, "00")
t1 = Val(intS) \ 60
Lspeed.Caption = sum / (t1 + 1) & "WPM"
End Sub
请大侠帮我改改
Dim x(4) As String * 104
Dim StartTime As String
Dim t1 As Long
Dim sum As Long
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
StartTime = Time
Call Import
Lspeed.Caption = "0 WPM"
End Sub
Private Sub Text1_Change(index As Integer)
Dim sub1, sub2 As String '定义 存放字符串的变量sub1和 sub2
Dim plong As Integer '定义存放picture中字符串长度的变量
Dim count As Long
count = 0: sum = 0
For k = 0 To 4
plong = 100 '将picture中字符串的长度存入plong
len1 = Len(Text1(k).Text) '将text中输入的字符串长度存入len1
For i = 1 To len1
sub1 = Mid(Text1(k), i, 1) '从text中i位置开始取一个字符
sub2 = Mid(x(k), i, 1) '从picture中从i开始取一个字符
count = count + 1: sum = sum + 1
If sub1 <> sub2 Then '当text中输入的字符和picture中的不一样的时候,将picture中的该字符重新打印并显示为红色
p1(k).ForeColor = vbRed '设置picture的前景色为红色
p1(k).CurrentY = 10 '定位x的当前位置
p1(k).CurrentX = (i - 1) * 8 '定位x的当前位置
p1(k).Print sub2 '将输错的字符在picture中用红色重新打印
count = count - 1
End If
If plong = len1 Then '一行输完后的处理
If k + 1 <= 4 Then
Text1(k + 1).SetFocus
plong = 0: len1 = 0
Else
p1(k).Cls
Text1(k) = ""
End If
End If
Next i
plong = 0: len1 = 0
Next k
Lright.Caption = Format((count / sum) * 100, "0.00") & "%"
End Sub
Private Sub Import()
For i = 0 To 4
Open App.Path + "\english.txt" For Input As #1
Line Input #1, x(i)
p1(i).CurrentY = 10
p1(i).Print x(i)
Close #1
Next i
End Sub
Private Sub Timer1_Timer()
Dim intS As Long
intS = Val(DateDiff("s", StartTime, Time))
Ltime.Caption = Format(intS \ 3600, "00") & ":" & Format((intS Mod 3600) \ 60, "00") & ":" & Format(intS Mod 60, "00")
t1 = Val(intS) \ 60
Lspeed.Caption = sum / (t1 + 1) & "WPM"
End Sub
请大侠帮我改改