Option Explicit Private Sub Form_Activate() Dim s As String, arr, out(1 To 6, 1 To 6) As String, n As Integer, m As Integer Dim i As Integer, j As Integer Open "c:\abc.txt" For Input As #1 Do While Not EOF(1) Line Input #1, s If Left(s, 1) <> "-" And Len(s) > 0 Then n = n + 1: m = 0 arr = Split(s) For i = 0 To UBound(arr) If arr(i) <> "" Then m = m + 1 out(n, m) = arr(i) End If Next out(n, m + 1) = CStr(Format((Val(out(n, m - 2)) + Val(out(n, m - 1)) + Val(out(n, m))) / 3, "0.00")) End If Loop Close #1 For i = 1 To UBound(out, 1) For j = 1 To 5 Print out(i, j), Next Print Next End Sub
温馨提示:答案为网友推荐,仅供参考