Excel_VBA课程设计实习报告---成绩管理系统.doc_第1页
Excel_VBA课程设计实习报告---成绩管理系统.doc_第2页
Excel_VBA课程设计实习报告---成绩管理系统.doc_第3页
Excel_VBA课程设计实习报告---成绩管理系统.doc_第4页
Excel_VBA课程设计实习报告---成绩管理系统.doc_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

课程设计实习报告 题目成绩管理系统 系别信息工程系 班级计算机应用技术姓名xxxxxxx 学号21起止时间 12月26日-1月6日20112012年目录一、实习目的1二、实习内容1三、实习过程1(一)实习准备1(二)表格和窗体的设计2(三)代码设计6四、实习日志22五、实习体会24 20112012学年excel vba实习报告vba是ofice中广泛使用的宏语言,使用宏可以增强word、excel等办公软件的自动化能力,使用户更高效地完成特定任务。excel处理对象多为数据,使用vba可以使繁琐和枯燥的工作变得简单易行。本学期的学习使我对vba有了深刻的认识,掌握vba的一些操作方法,本次的实习使我对vba的实际运用又有了进一步的了解。一、实习目的掌握vba程序设计语言的基础知识,并开发一个基于数据库的高效办公应用系统,通过实习能达到利用vba编程思想和技巧,实现各种高效自动化办公应用,能建立友好的图形用户界面,能正确地进行数据库服务器和数据库中数据的操作。二、实习内容题目:(项目二)成绩管理系统本项目利用vba实现学生成绩评估的自动化,使学校提高对考生成绩分析的效率,从而提高学校考试系统的自动化。三、实习过程(一)实习准备在任何程序设计时,都需要有缜密的设计思路。本次是“成绩管理系统”,结合学校的实际情况,首先对问题和需求进行分析,其次对项目的功能进行分析。得出项目设计流程图学生成绩管理系统信息录入与更新学生考试情况分析学生整体考试情况学生信息录入学生个体考试情况学生分数信息录入学生成绩的打印退出系统(二)表格和窗体的设计在开始编写代码前,需要设计好需要的每个工作表的框架,以便调用。首先设计了学生信息表,在第二行中一次输入编号、姓名、性别、班级字段,如图 2。设计学生分数表用来录入学生的考试成绩,涉及字段为:编号、姓名、数学、英语、语文、物理、化学、生物、体育、总分;如图 1。设计统计学生整体情况的统计表;如图 3图 1 学生分数信息表图 2 学生信息表图 3 统计表本次实习涉及到窗体,我采用先设计窗体再编写代码的方式。添加与更新学生信息窗体,添加与更新学生分数信息窗体,如图所示。 图 4 添加与更新学生信息窗体图 5 添加与更新学生分数信息窗体 图 6 分数查询(普通查找与高级查找)窗体(三)代码设计相关窗体设计完成后,接下来就是编写相关的功能代码,有了代码窗体的功能才能充分体现。首先是添加与更新学生信息窗体的“确定”按钮编写相应代码,主要代码如下:private sub commandbutton1_click()dim tempy as integerdim setflag as booleansetflag = truetempy = 3 if (trim(textbox1.text) = ) or (trim(textbox2.text) = ) then msgbox 请输入编号和姓名,确保一致, vbokonly, 警告! endend ifwhile (not isempty(sheets(学生信息表).cells(tempy, 1).value) if (trim(textbox1.text = sheets(学生信息表).cells(tempy, 1).value) then sheets(学生信息表).cells(tempy, 1).value = textbox1.text sheets(学生信息表).cells(tempy, 2).value = textbox2.text if (trim(combobox1.text ) then sheets(学生信息表).cells(tempy, 3).value = combobox1.text end if if (trim(textbox4.text ) then sheets(学生信息表).cells(tempy, 4).value = textbox4.text end if setflag = false goto renew end if tempy = tempy + 1wendwhile (not isempty(sheets(学生信息表).cells(tempy, 1).value)if (trim(textbox1.text = sheets(学生信息表).cells(tempy, 1).value) then setflag = false goto renew end if tempy = tempy + 1wendrenew: if (setflag) then if (vbok = msgbox(没有找到该学生信息,是否新加入条目, vbokcancel, 提示) then sheets(学生信息表).cells(tempy, 1).value = textbox1.text sheets(学生信息表).cells(tempy, 2).value = textbox2.text if (trim(combobox1.text ) then sheets(学生信息表).cells(tempy, 3).value = combobox1.text end if if (trim(textbox4.text ) then sheets(学生信息表).cells(tempy, 4).value = textbox4.text end if end if end ifend sub窗体的效果如下图所示:输入学生信息后,单机“确定”按钮后,如果找到相应的学生信息将会更新学生信息,如果没有相关学生信息,将弹出是否添加学生信息的对话框。如图 7所示图 7当查找到学生信息需要删除时,点击删除按钮。相应代码为:private sub commandbutton4_click()dim tempy as integertempy = 3按照编号搜索记录if (trim(textbox5.text) ) thenwhile (not isempty(sheets(学生信息表).cells(tempy, 1).value) if (textbox5.text = sheets(学生信息表).cells(tempy, 1).value) then sheets(学生信息表).select sheets(学生信息表).range(a & cstr(tempy) & :d & cstr(tempy).selectdim shanchu as integershanchu = msgbox(确定删除学生信息?, vbyesno, 提示:)if shanchu = 6 then sheets(学生信息表).range(a & cstr(tempy) & :d & cstr(tempy).delete shift:=xlup msgbox 删除学生信息成功!, vbokonly, 提示: end if end if tempy = tempy + 1wendelseif (trim(textbox6.text) ) thenwhile (not isempty(sheets(学生信息表).cells(tempy, 1).value)if (textbox6.text = sheets(学生信息表).cells(tempy, 2).value) then sheets(学生信息表).select sheets(学生信息表).range(a & cstr(tempy) & :d & cstr(tempy).selectshanchu = msgbox(确定删除学生信息?, vbyesno, 提示:) if shanchu = 6 then sheets(学生信息表).range(a & cstr(tempy) & :d & cstr(tempy).delete shift:=xlup msgbox 删除学生信息成功!, vbokonly, 提示:end if end if tempy = tempy + 1 wend elsemsgbox 请选择要删除的学生编号或姓名!, vbokonly, 提示: end ifend sub当需要删除学生信息时,如果没有输入学生的条件编号或者姓名,将弹出提示输入删除条件的对话框;当输入了学生的编号或姓名,将弹出确认删除的信息框。如下图所示: 图 8 删除学生信息添加与更新学生分数的窗体代码:private sub commandbutton1_click()dim tempy as integerdim setflag as booleansetflag = truetempy = 3 if (trim(textbox1.text) = ) or (trim(textbox2.text) = ) then msgbox 请输入编号和姓名,确保一致, vbokonly, 警告! endend ifwhile (not isempty(sheets(学生分数表).cells(tempy, 1).value) if (trim(textbox1.text = sheets(学生分数表).cells(tempy, 1).value) then sheets(学生分数表).cells(tempy, 1).value = textbox1.text sheets(学生分数表).cells(tempy, 2).value = textbox2.text if (trim(textbox3.text ) then sheets(学生分数表).cells(tempy, 3).value = textbox3.text end if if (trim(textbox4.text ) then sheets(学生分数表).cells(tempy, 4).value = textbox4.text end if if (trim(textbox5.text ) then sheets(学生分数表).cells(tempy, 5).value = textbox5.text end if if (trim(textbox6.text ) then sheets(学生分数表).cells(tempy, 6).value = textbox6.text end if if (trim(textbox7.text ) then sheets(学生分数表).cells(tempy, 7).value = textbox7.text end if if (trim(textbox8.text ) then sheets(学生分数表).cells(tempy, 8).value = textbox8.text end if if (trim(textbox9.text ) then sheets(学生分数表).cells(tempy, 9).value = textbox9.text end if setflag = false goto renew end if tempy = tempy + 1wendwhile (not isempty(sheets(学生分数表).cells(tempy, 1).value) if (trim(textbox1.text = sheets(学生分数表).cells(tempy, 1).value) then setflag = false goto renew end if tempy = tempy + 1wendrenew: if (setflag) then if (vbok = msgbox(没有找到该学生信息,是否新加入条目, vbokcancel, 提示) then sheets(学生分数表).cells(tempy, 1).value = textbox1.text sheets(学生分数表).cells(tempy, 2).value = textbox2.text if (trim(textbox3.text ) then sheets(学生分数表).cells(tempy, 3).value = textbox3.text end if if (trim(textbox4.text ) then sheets(学生分数表).cells(tempy, 4).value = textbox4.text end if if (trim(textbox5.text ) then sheets(学生分数表).cells(tempy, 5).value = textbox5.text end if if (trim(textbox6.text ) then sheets(学生分数表).cells(tempy, 6).value = textbox6.text end if if (trim(textbox7.text ) then sheets(学生分数表).cells(tempy, 7).value = textbox7.text end if if (trim(textbox8.text ) then sheets(学生分数表).cells(tempy, 8).value = textbox8.text end if if (trim(textbox9.text ) then sheets(学生分数表).cells(tempy, 9).value = textbox9.text end if end if end if qinkonend sub当添加学生分数时将检查是否已有该生的分数记录,如果有该学生的记录将进行更新,如果没有相关信息将提示是否添加新的记录。单击“确定”按钮后,界面输入的内容将自动清空,方便添加下一条记录。图 9 添加与更新学生分数信息框为了方便快速的找到所要学生的分数信息,本项目提供了查找功能,可以通过输入学生编号或姓名查询该生的分数信息,也可以根据分数信息查询相关的学生信息。主要代码如下:private sub commandbutton1_click()dim tempy as integertempy = 3if (trim(textbox1.text) ) thenwhile (not isempty(sheets(学生分数表).cells(tempy, 1).value) if (textbox1.text = sheets(学生分数表).cells(tempy, 1).value) then sheets(学生分数表).select sheets(学生分数表).range(a & cstr(tempy) & :j & cstr(tempy).select end if tempy = tempy + 1 wend按姓名搜所elseif (trim(textbox2.text) ) thenwhile (not isempty(sheets(学生分数表).cells(tempy, 1).value) if (textbox2.text = sheets(学生分数表).cells(tempy, 2).value) then sheets(学生分数表).select sheets(学生分数表).range(a & cstr(tempy) & :j & cstr(tempy).select end if tempy = tempy + 1 wend else mei you xin xi shu ru msgbox 请输入查询条件, vbokonly, 提示: end ifend sub该段代码用来实现通过输入学生的编号或姓名来找到相应的分数信息。效果如图:图 10 通过编号或姓名的方式查找相应信息 高级查找代码:public function searchvalue(byval colvalue as integer, byval numbervalue as integer, byval limitnum as integer)dim tempy as integerdim tempflag as booleantempflag = truetempy = 3sheets(学生分数表).select进入逐行循环while (not isempty(sheets(学生分数表).cells(tempy, 1).value) if (numbervalue = 1) then if (sheets(学生分数表).cells(tempy, 1).offset(0, (colvalue + 1).value limitnum) thenif (vbok = msgbox(是 & sheets(学生分数表).cells(tempy, 2).value & 吗?, vbokcancel, 确认) thensheets(学生分数表).range(a & cstr(tempy) & :j & cstr(tempy).select end end if end ifend if tempy = tempy + 1 wend if (tempflag) then msgbox 没有找到该学生, vbokonly, 查找失败! end ifend function该段代码通过分数信息来找到相应的学生。单击“确定”按钮后将弹出确认对话框询问是否要查找该生,单击“取消”将查询下一条符合筛选规则的记录,单击“确定”按钮将选中有该姓名的记录,如果没有需要的信息将显示查找失败的内容。如图所示:图 11 高级查询接下来就是分数单的相关代码。分数单是用来发给学生成绩信息的,就要求有完整的信息内容。需要在相应的分数上有相应的科目标题。主要代码如下:private sub commandbutton1_click()dim tempx as integerdim tempy as integerdim tempz as integertempz = 3tempy = 4while (not isempty(sheets(学生分数表).cells(tempz, 1).value) tempx = 1 while (not isempty(sheets(学生分数表).cells(2, tempx).value) sheets(分数单).cells(tempy, tempx).value = sheets(学生分数表).cells(2, tempx).value sheets(分数单).cells(tempy + 1, tempx).value = sheets(学生分数表).cells(tempz, tempx).value tempx = tempx + 1 wend tempy = tempy + 2 tempz = tempz + 1 wendend sub本段代码实现在“分数单”表中生成分数单。当单击“生成分数单”按钮后将生成一个学生成绩的分数单。如图所示:图 12 生成分数单使用统计表对学生考试情况的整体分析,主要代码设计:while (not isempty(sheets(学生信息表).cells(l, 1).value) if (一班 = sheets(学生信息表).cells(l, 4).value) then bji1 = bji1 + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then bji1fs = bji1fs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend elseif (二班 = sheets(学生信息表).cells(l, 4).value) then bji2 = bji2 + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then bji2fs = bji2fs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend elseif (三班 = sheets(学生信息表).cells(l, 4).value) then bji3 = bji3 + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then bji3fs = bji3fs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend elseif (四班 = sheets(学生信息表).cells(l, 4).value) then bji4 = bji4 + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then bji4fs = bji4fs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend end if if (男 = sheets(学生信息表).cells(l, 3).value) then nan = nan + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then nanfs = nanfs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend elseif (女 = sheets(学生信息表).cells(l, 3).value) then nv = nv + 1 h = 3 while (not isempty(sheets(学生分数表).cells(h, 1).value) if (sheets(学生信息表).cells(l, 1).value = sheets(学生分数表).cells(h, 1).value) then nvfs = nvfs + cint(sheets(学生分数表).cells(h, 10).value) end if h = h + 1 wend end if l = l + 1 wend此段代码实现在学生信息表中循环查找记录和循环查找分数记录。sheets(统计表).cells(7, 7).value = bji1sheets(统计表).cells(8, 7).value = bji2sheets(统计表).cells(9, 7).value = bji3sheets(统计表).cells(10, 7).value = bji4sheets(统计表).cells(12, 7).value = bji1 + bji2 + bji3 + bji4sheets(统计表).cells(14, 7).value = nansheets(统计表).cells(15, 7).value = nvsheets(统计表).cells(7, 8).value = bji1fs / bji1sheets(统计表).cells(8, 8).value = bji2fs / bji2sheets(统计表).cells(9, 8).value = bji3fs / bji3sheets(统计表).cells(10, 8).value = bji4fs / bji4sheets(统计表).cells(12, 8).value = (bji1fs + bji2fs + bji3fs + bji4fs) / (bji1 + bji2 + bji3 + bji4)sheets(统计表).cells(14, 8).value = nanfs / nansheets(统计表).cells(15, 8).value = nvfs / nv此段代码实现将找到的记录自动写入统计表中对应的项目中。图 13 统计表生成数据为了引导使用者快速了解本项目的各种功能,为此项目添加了一个主界面。如图所示:图 14 主界面设计四、实习日志2011年12月26日 星期一今天是实习的第一天,根据个人能力和实习安排的时间我选择做“成绩管理系统”,本项目利用vba来实现学生成绩评估的自动化。在设计本项目之前,我首先进行了问题和需求的分析。结合学校的情况,围绕如何分析考生的情况和如何统计总体考试情况,得出我的项目至少应具备提供单个考生信息和按教师需要的指标来分析整体的水平这两个功能。但在设计代码前还要将系统的各个步骤进行细化。项目在具有所需的功能的同时,作为一个系统应该是完整的体系,这就要加入其他的辅助功能来保证项目的完整。因此在我的项目中应该考虑到存放学生信息和分数信息,要有分数录入和更改的功能,要有学生信息录入和更改的功能,要能够提供查找功能让老师可以迅

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论