用vb写一个文件读取程序,程序!

输入姓名学号好几课成绩,存入一个文件,排序后再输出,并存入另一个文件!... 输入姓名学号好几课成绩,存入一个文件,排序后再输出,并存入另一个文件! 展开
 我来答
黎约圣殿ULMA
2014-09-25 · 超过66用户采纳过TA的回答
知道答主
回答量:142
采纳率:100%
帮助的人:60万
展开全部
Option Base 1 Private Sub Command1_Click() Dim re() As record ReDim re(n) Dim i% Open "d:\stud1.dat" For Append As #1 For i = 1 To n re(i).Nu = InputBox("请输入学号!") re(i).Na = InputBox("请输入姓名!") re(i).Ma = InputBox("请输入数学成绩!") re(i).Ch = InputBox("请输入化学成绩!") re(i).Co = InputBox("请输入计算机成绩!") Write #1, re(i).Nu, re(i).Na, re(i).Ma, re(i).Ch, re(i).Co Next Close #1 End Sub Private Sub Command2_Click() Dim re() As record, su() As Integer, av() As Single Dim i%, j%, k%, temp%, temp1% ReDim re(n + 1), su(n + 1), av(n + 1) Kill "d:\stud2.dat" Form1.Cls Open "d:\stud1.dat" For Input As #1 For i = 1 To n + 1 Input #1, re(i).Nu, re(i).Na, re(i).Ma, re(i).Ch, re(i).Co Next Close #1 For i = 2 To n + 1 su(i) = re(i).Ma + re(i).Ch + re(i).Co av(i) = su(i) / 3 Next i For i = 2 To n k = i + 1 For j = k To n + 1 If su(i) < su(j) Then temp = su(i): su(i) = su(j): su(j) = temp temp1 = re(i).Nu: re(i).Nu = re(j).Nu: re(j).Nu = temp1 temp1 = re(i).Na: re(i).Na = re(j).Na: re(j).Na = temp1 temp1 = re(i).Ma: re(i).Ma = re(j).Ma: re(j).Ma = temp1 temp1 = re(i).Ch: re(i).Ch = re(j).Ch: re(j).Ch = temp1 temp1 = re(i).Co: re(i).Co = re(j).Co: re(j).Co = temp1 temp = av(i): av(i) = av(j): av(j) = temp End If Next j Next i Open "d:\stud2.dat" For Append As #2 Write #2, "学号", "姓名", "数学", "化学", "计算机", "平均分", "总分" Print "学号", "姓名", "数学", "化学", "计算机", "平均分", "总分" For i = 2 To n + 1 Write #2, re(i).Nu, re(i).Na, re(i).Ma, re(i).Ch, re(i).Co, av(i), su(i) Print re(i).Nu, re(i).Na, re(i).Ma, re(i).Ch, re(i).Co, av(i), su(i) Next i Close #2 End Sub

求采纳
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式