Private Sub Command1_Click()
Dim strfilename As String
Dim strline As String
Dim filenum As String
CommonDialog1.Filter = "所有文件(*.*)|*.*"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowOpen
strfilename = CommonDialog1.FileName
Text1.Text = ""
filenum = FreeFile
If strfilename <> "" Then
Open strfilename For Input As filenum
Do While Not EOF(filenum)
Line Input #filenum, strline
Text1.Text = Text1.Text + strline + Chr(13) + Chr(10)
Loop
Close filenum
End If
End Sub
Private Sub Command2_Click()
Dim a(1000) As String
strfilename = CommonDialog1.FileName
Text1.Text = ""
filenum = FreeFile
If strfilename <> "" Then
Open strfilename For Input As filenum
Do While Not EOF(filenum)
Line Input #filenum, strline
n = LTrim(strline)
s1:
For i = 1 To Len(n)
If Mid(n, i, 1) = " " Then
k = k + 1
a(k) = Mid(n, 1, i - 1)
n = LTrim(Mid(n, i))
GoTo s1
End If
Next i
For j = 1 To Len(RTrim(strline))
If Mid(RTrim(strline), Len(RTrim(strline)) - j, 1) = " " Then
k = k + 1
a(k) = Mid(RTrim(strline), Len(RTrim(strline)) - j + 1, Len(RTrim(strline)))
Exit For
End If
Next j
Text1.Text = Text1.Text + strline + Chr(13) + Chr(10)
Loop
Close filenum
End If
For i = 1 To k
Text2.Text = Text2.Text & " " & Trim(a(i))
If i Mod 6 = 0 Then
Text2.Text = Text2.Text & Chr(13) & Chr(10)
End If
Next i
If Text3.Text = "" Then
MsgBox "请输入要比较的值!"
Text3.SetFocus
Exit Sub
End If
Dim o, v As Single
Dim m As Single
m = Val(Text3.Text)
k = Val(Text3.Text)
For i = 1 To k - 5 Step 6
If Val(a(i)) > m Then
Exit For
End If
Next i
If i = 1 Then Exit Sub
v = (Val(a(i + 1)) - Val(a(i - 6 + 1))) / (Val(a(i + 3)) - Val(a(i - 6 + 3)))
o = (Val(a(i - 1)) - Val(a(i + 5))) * m
Text4.Text = Str(v) & Str(o)
End Sub
帮你弄了几个小时,终于搞定了....是按照你上面的要求改的......你看看有什么地方错了没?