1、vb实习报告计算机上机实习(vb)专业班级:油工10901学生学号:200906829学生姓名:方 飞 飞班级序号: 4指导老师:冯 翠 丽完成日期:2010-12-17一 设计题目 学生成绩管理系统二 设计思路从文本中读取文件数据,利用split函数对读取的数据进行分割并赋值,利用VB的顺序结构,选择结构,循环结构编写程序代码,最终将各代码写入界面设计中的各菜单下。三 程序实现的目标本程序将实现从文本中读取数据,赋值数据,运算数据,实现对学生的加权平均值,名次,全班每门课的分数段,不及格同学名单,优等生名单等运算,并写入文件。四 程序设计框图五数据处理原始成绩 课程学分成绩学分加权平均分排名
2、不及格学生名单 优等生名单各分数人数六源程序模块:Type studentsno As String * 6sname As String * 3a(1 To 5) As Integeraver As Singlemc As Integerfei As IntegerEnd TypeType kechenbh As Stringkcm As Stringxf As Singlef(1 To 5) As IntegerEnd Type窗体代码 :Dim kc() As kechenDim m As IntegerDim stud() As studentDim st As StringDim n
3、 As IntegerDim st2 As StringDim zxf As IntegerPrivate Sub Average_Click()Picture1.ClsFor j = 1 To nstud(j).aver = 0For i = 1 To 5stud(j).aver = stud(j).aver + Val(stud(j).a(i) * Val(kc(i).xf)Next istud(j).aver = stud(j).aver / zxfNext jPicture1.Print st; Space(4); 平均分For i = 1 To nPicture1.Print stu
4、d(i).sno; Space(5); stud(i).sname; Space(2);For j = 1 To mPicture1.Print stud(i).a(j); Space(3);Next jPicture1.Print Format(stud(i).aver, 0.00)Next iEnd SubPrivate Sub Form_Load()Dim ch As String, c() As String, i%, d() As Stringn = 0: k = 0Open App.Path + 成绩.txt For Input As #1Line Input #1, stPrin
5、t stDo While Not EOF(1)Line Input #1, chch = Trim(ch)ch = delspace(ch)c = Split(ch, )n = n + 1ReDim Preserve stud(n) stud(n).sno = c(0) stud(n).sname = c(1) stud(n).a(1) = c(2) stud(n).a(2) = c(3) stud(n).a(3) = c(4) stud(n).a(4) = c(5) stud(n).a(5) = c(6)LoopClose #1Open App.Path + 学分.txt For Input
6、 As #1Line Input #1, st2Do While Not EOF(1)Line Input #1, chch = Trim(ch)ch = delspace(ch)d = Split(ch, )m = m + 1ReDim Preserve kc(1 To m)kc(m).bh = d(0)kc(m).kcm = d(1)kc(m).xf = d(2)zxf = zxf + kc(m).xfLoopClose #1 End SubPublic Function delspace(s As String) As Stringk = InStr(s, )Do While k 0s
7、= Replace(s, , )k = InStr(s, )Loopdelspace = sEnd FunctionPrivate Sub fsd_Click()Picture1.ClsDim fw(1 To 5) As StringPicture1.Clsfw(1) = =90fw(2) = 80-89fw(3) = 70-79fw(4) = 60-69fw(5) = = 90 Thenkc(j).f(1) = kc(j).f(1) + 1ElseIf stud(i).a(j) = 80 Thenkc(j).f(2) = kc(j).f(2) + 1ElseIf stud(i).a(j) =
8、 70 Thenkc(j).f(3) = kc(j).f(3) + 1ElseIf stud(i).a(j) = 60 Thenkc(j).f(4) = kc(j).f(4) + 1Elsekc(j).f(5) = kc(j).f(5) + 1End IfNext jNext iPicture1.Print 范围 英语 制图 数学 物理 化学Print #1, 范围 英语 制图 数学 物理 化学For j = 1 To 5Print #1, fw(j); Space(4);Picture1.Print fw(j); Space(4);For i = 1 To mPrint #1, kc(i).
9、f(j); Space(3);Picture1.Print kc(i).f(j); Space(4);Next iPicture1.PrintPrint #1,Next jClose #1End SubPrivate Sub minci_Click()Picture1.ClsFor i = 1 To nstud(i).mc = 1For j = 1 To nIf stud(i).aver stud(j).aver Thenstud(i).mc = stud(i).mc + 1End IfNext jNext iPicture1.Print 学号, 姓名, 名次For i = 1 To nPic
10、ture1.Print stud(i).sno, stud(i).sname, stud(i).mcNext iEnd SubPrivate Sub Print59_Click()Picture1.ClsOpen App.Path + 不及格学生名单.txt For Output As #1Picture1.Print 学号 姓名 不及格课程名 成绩 学分 Print #1, 学号 姓名 不及格课程名 成绩 学分 For i = 1 To nFor j = 1 To mIf stud(i).a(j) = 95 Thenss = ss + 1End IfNext jIf ss = 2 ThenI
11、f stud(i).aver = 85 Thenstud(i).fei = 1End IfEnd IfNext iPrint #1, st; Space(3); 平均分; Space(3); 名次Picture1.Print st; Space(3); 平均分; Space(3); 名次For i = 1 To nIf stud(i).mc = 90 Or stud(i).fei = 1 ThenPrint #1, stud(i).sno; Space(5); stud(i).sname; Space(2);Picture1.Print stud(i).sno; Space(5); stud(
12、i).sname; Space(2);For j = 1 To mPrint #1, stud(i).a(j); Space(3);Picture1.Print stud(i).a(j); Space(3);Next jPrint #1, Format(stud(i).aver, 0.00); Space(4); stud(i).mcPicture1.Print Format(stud(i).aver, 0.00); Space(4); stud(i).mcEnd IfNext iClose #1End SubPrivate Sub yaunkc_Click()Picture1.ClsPict
13、ure1.Print 编号 课程名称 课程学分For i = 1 To mPicture1.Print kc(i).bh, kc(i).kcm, kc(i).xfNext iEnd SubPrivate Sub yuancj_Click()Picture1.ClsPicture1.Print stFor i = 1 To nPicture1.Print stud(i).sno; Space(5); stud(i).sname; Space(2);For j = 1 To mPicture1.Print stud(i).a(j); Space(3);Next jPicture1.PrintNext iEnd Sub七小结 在这次VB程序设计实习中,我逐渐了解了程序在VB 6.0中调试并运行的方法,在其过程中,遇到了很多问题和困难,发现在之前的学习中,所学的东西不能完全掌握。这次实习,是我在学习上的一次考验,让我深深体会到了实训操作的重要性。同时感谢老师给予的耐心讲解,细心的帮助调试程序。虽然此次实习已结束,时间不长,但意义很大。它使我了解自己的短处,让我知道要从什么方面对自己进行补充,同时培养了我独立思考,求异思维的能力。我深信这次课程设计,对我的VB学习以及今后的计算机等级考试的学习和考试会起到很大的促进作用,这对我今后的学习和工作将产生很大的影响。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1