请教VB编程的题目,急,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:00:58
文件名为grade.txt的文件里有8行data,如下
108194
7
10
10
197526
8
9
7
大的那个数字是学生编号,小的几个是三次测验成绩,现在要编个button的code,使得按了后能够在另一个名为output.txt的文件中显示每个学生的编号和平均成绩,大致格式如下:
108194 9
197526 8

还有,请使用类似下面的这种方法编程,谢谢
Private Sub btnCompute_Click(...) Handles btnCompute.Click
Dim sr As IO.StreamReader = IO.File.OpenText("grade.txt")
Dim student,total As Double
student = sr.ReadLine
total += CDbl(sr.ReadLine)
.....

private sub command1_click()
dim R as string,S as integer,K as string
open "c:\grade.txt" for input as #1
open "c:\output.txt" for output as #2
do while not eof(1)
line input #1,R
line input #1,k
s=s+val(k)
line input #1,k
s=s+val(k)
line input #1,k
s=s+val(k)
print #2,r;s/3
loop
close
end sub