本科毕业设计(论文)代码题目:基于VB的驾驶员理论考试模拟系统的设计与实现学生姓名:张文江院(系):计算机学院专业班级:计1201指导教师:韩建宁完成时间:2016年6月5日代码清单1.Modulel.basPublic Cn As New ADODB.ConnectionPublic UserID As String''用户账号Public UserName As String'用户姓名Public UserType As String''用户类型Public strTableName As String''表名Public mFso As New FileSystemObjectPublic ksKm As String'考试科目Public ksMk As String'模块Type KsDataksName As String'试卷名称ksTime As Integer'考试时间pdtSum As Integer'判断题总数pdtValue As Integer'判断每题分值pdtNdSum(2)As Integer'判断题各难度题数dstSum As Integer'单选题总数dstValue As Integer'单选题每题分值dstNdSum(2)As Integer'各难度题数End TypePublic ksInfo As KsData''考试数据Sub ConnectData()If Cn.State Then Cn.Close'Cn.ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=驾驶员理论考试;Data Source=."Cn.ConnectionString="driver={sqlserver};server=WIN7U-20141007T;uid=sa;pwd=hcx112531;Database=驾驶员理论考试" Cn.OpenEnd SubSub LoadGrid(mfg As MSHFlexGrid,rstSql As String)Dim rst As New ADODB.Recordsetrst.Open rstSql,Cn,adOpenStatic,adLockReadOnlyWith mfg.Clear.Rows=2.Cols=rst.Fields.CountFor i=0To rst.Fields.Count-1.TextMatrix(0,i)=Trim(rst(i).Name).ColWidth(i)=(.Width-500)/.ColsNext iWhile Not rst.EOFFor i=0To rst.Fields.Count-1If Not IsNull(rst(i))Then.TextMatrix(.Rows-1,i)=Trim(rst(i)) Next i.Rows=.Rows+1rst.MoveNextWendEnd WithEnd Sub2.登陆提醒界面frmts.frmPrivate Sub Command1_Click()If Check1.Value=1ThenUnload MefrmLogin.ShowElseMsgBox"请在我已阅读上打勾!"End IfEnd SubPrivate Sub Command2_Click()EndEnd Sub3.登陆界面frmLogin.frmDim CountLogin As IntegerPrivate Sub Command1_Click()'登录If Trim(Text1.Text)=""Then MsgBox"用户账号不能为空":Exit SubIf Trim(Text2.Text)=""Then MsgBox"用户账号不能为空":Exit SubIf Trim(Combo1.Text)=""Then MsgBox"用户类型不能为空":Exit SubIf Trim(Text3.Text)=""Then MsgBox"密码不能为空":Exit SubDim rsLogin As New ADODB.RecordsetrsLogin.Open"select*from用户信息表where用户姓名='"&Text1.Text&"'and 用户账号='"&Text2.Text&"'and密码='"&Text3.Text&"'and权限='"& Combo1.Text&"'",Cn,adOpenStatic,adLockReadOnlyIf Not rsLogin.EOF ThenUserID=Text2.TextUserName=Text1.TextUserType=Combo1.TextIf Trim(Combo1.Text)="管理员"ThenfrmAdmin.ShowElsefrmKs.ShowEnd IfUnload MeElseCountLogin=CountLogin+1MsgBox"用户或密码错误!"If CountLogin>=3Then Unload MeEnd IfEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Command3_Click()frmUserReg.Show1End SubPrivate Sub Form_Load()Call ConnectDataEnd SubPrivate Sub Label3_Click()End Sub4.考生注册界面frmUserReg.frmPrivate Sub Command1_Click()For i=0To3If Trim(Text1(i).Text)=""Then MsgBox"数据不全!":Exit SubNextIf Trim(Text1(2).Text)<>Trim(Text1(3).Text)Then MsgBox"密码不正确!":Exit SubDim rst As New ADODB.Recordsetrst.Open"select*from用户信息表where用户账号='"&Trim(Text1(1).Text)&"'", Cn,adOpenStatic,adLockOptimisticIf Not rst.EOF ThenMsgBox"此账号已存在!"Exit SubElserst.AddNewrst(0).Value=Trim(Text1(0).Text)rst(1).Value=Trim(Text1(1).Text)rst(2).Value=Trim(Text1(2).Text)rst(3).Value="考生"rst.UpdateMsgBox"新用户注册成功!"Unload MeEnd IfEnd SubPrivate Sub Command2_Click() Unload MeEnd Sub5.管理员界面frmAdmin.frm Private Sub Command1_Click() frmUser.Show1End SubPrivate Sub Command2_Click() frmpsd.Show1End SubPrivate Sub Command3_Click() frmfindCj.Show1End SubPrivate Sub Command4_Click() frmSetPaper.Show1End SubPrivate Sub Command5_Click()frmSt.Show1End SubPrivate Sub Command7_Click()EndEnd Sub6.用户管理界面frmUser.frmPrivate Sub Command1_Click()''添加用户For i=0To3If Trim(Combo1(i).Text)=""Then MsgBox"数据不全!":Exit SubNext iDim rstUser As New ADODB.RecordsetrstUser.Open"select*from用户信息表where用户账号='"&Combo1(1).Text&"'", Cn,adOpenStatic,adLockOptimisticIf Not rstUser.EOF ThenMsgBox"此用户名已存在,不能重复添加!":Exit SubElserstUser.AddNewrstUser(0).Value=Trim(Combo1(0).Text)rstUser(1).Value=Trim(Combo1(1).Text)rstUser(2).Value=Trim(Combo1(2).Text)rstUser(3).Value=Trim(Combo1(3).Text)rstUser.UpdateMsgBox"添加成功!"Call LoadGrid(MSHFlexGrid1,"select*from用户信息表")End IfEnd SubPrivate Sub Command2_Click()''删除用户For i=0To3If Trim(Combo1(i).Text)=""Then MsgBox"数据不全!":Exit SubNext iWith MSHFlexGrid1If Trim(.TextMatrix(.Row,1))<>""ThenIf MsgBox("真的删除吗?用户账号为:"&Trim(.TextMatrix(.Row,1)), vbYesNo)=vbNo Then Exit SubCn.Execute"delete from用户信息表where用户账号='"& Trim(.TextMatrix(.Row,1))&"'"Call LoadGrid(MSHFlexGrid1,"select*from用户信息表")ElseMsgBox"请选择用户!"End IfEnd WithEnd SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Command4_Click()'修改For i=0To3If Trim(Combo1(i).Text)=""Then MsgBox"数据不全!":Exit SubNext iDim rstUser As New ADODB.RecordsetrstUser.Open"select*from用户信息表where用户账号='"&Combo1(1).Text&"'", Cn,adOpenStatic,adLockOptimisticIf Not rstUser.EOF ThenrstUser(0).Value=Trim(Combo1(0).Text)rstUser(1).Value=Trim(Combo1(1).Text)rstUser(2).Value=Trim(Combo1(2).Text)rstUser(3).Value=Trim(Combo1(3).Text)rstUser.UpdateMsgBox"修改成功!"Call LoadGrid(MSHFlexGrid1,"select*from用户信息表")ElseMsgBox"此用户账号不存在!":Exit SubEnd IfEnd SubPrivate Sub Form_Load()Call LoadGrid(MSHFlexGrid1,"select*from用户信息表")End SubPrivate Sub MSHFlexGrid1_Click()With MSHFlexGrid1For i=0To.Cols-1If Trim(.TextMatrix(.Row,3))=""ThenIf i<3Then Combo1(i).Text=Trim(.TextMatrix(.Row,i)) ElseCombo1(i).Text=Trim(.TextMatrix(.Row,i))End IfNextEnd WithEnd Sub7.密码管理界面frmpsd.frmPrivate Sub cmdExit_Click()Unload MeEnd SubPrivate Sub Command4_Click()'''密码修改On Error GoTo ErrIf Trim(Text13.Text)<>""And Trim(Text14.Text)<>""And Trim(Text15.Text)<>"" ThenIf Trim(Text14.Text)<>Trim(Text15.Text)ThenMsgBox"新密码不对!",,"提示"Exit SubElseDim rs1As New ADODB.RecordsetIf rs1.State Then rs1.Closers1.Open"select用户账号,密码from用户信息表where用户账号='"& UserID&"'",Cn,adOpenStatic,adLockOptimisticIf Not rs1.EOF ThenIf Not IsNull(rs1.Fields(1))ThenIf Trim(Text13.Text)<>Trim(rs1.Fields(1))ThenMsgBox"用户旧密码不对!",,"提示"Exit SubElsers1.Fields(1).Value=Trim(Text14.Text)rs1.UpdateMsgBox"操作已成功!",,"提示"Unload MeEnd IfEnd IfEnd IfEnd IfEnd IfExit SubErr:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Load()Text1.Text=UserIDEnd Sub8.成绩查询界面frmfindCJ.frmPrivate Sub Command1_Click()Dim rst As New ADODB.RecordsetDim strSql As StringstrSql="select试卷名称,用户账号,用户姓名,成绩from考生成绩信息where成绩>0"If Trim(Text1.Text)<>""ThenstrSql=strSql&"and用户姓名='"&Trim(Text1.Text)&"'"End IfIf Trim(Text2.Text)<>""ThenstrSql=strSql&"and用户账号='"&Trim(Text2.Text)&"'"End IfIf Option1.Value=True ThenstrSql=strSql&"order by用户账号"ElsestrSql=strSql&"order by成绩desc"End IfCall LoadGrid(MSHFlexGrid1,strSql)End SubPrivate Sub Command2_Click()Unload MeEnd Sub9.试卷参数设置界面frmSetPaper.frmPrivate Sub Command1_Click()''保存Dim rst As New ADODB.Recordsetrst.Open"select*from试卷参数",Cn,adOpenStatic,adLockOptimisticIf rst.EOF Then rst.AddNewFor i=0To rst.Fields.Count-1rst(i).Value=Trim(Text1(i).Text)Nextrst.UpdateMsgBox"设置成功!"End SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim rst As New ADODB.Recordsetrst.Open"select*from试卷参数",Cn,adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenFor i=0To rst.Fields.Count-1If Not IsNull(rst(i))Then Text1(i).Text=Trim(rst(i))Next iEnd IfEnd SubPrivate Sub Text1_Change(Index As Integer)Text1(11).Text=Val(Text1(1).Text)+Val(Text1(6).Text)If Val(Text1(2).Text)>0Then Text2.Text=Val(Text1(1).Text)/Val(Text1(2).Text) If Val(Text1(7).Text)>0Then Text3.Text=Val(Text1(6).Text)/Val(Text1(7).Text) Text1(5).Text=Val(Text1(2).Text)-Val(Text1(3).Text)-Val(Text1(4).Text) Text1(10).Text=Val(Text1(7).Text)-Val(Text1(8).Text)-Val(Text1(9).Text) End Sub10.试题管理界面frmSt.frmPrivate Sub Combo1_Click()Combo2.ClearIf Trim(Combo1.Text)="科目"ThenCombo2.AddItem"科目一"Combo2.AddItem"科目四"ElseIf Trim(Combo1.Text)="模块"ThenCombo2.AddItem"道路交通安全法律法规和规章"Combo2.AddItem"道路交通信号"Combo2.AddItem"安全行车文明驾驶基础知识"Combo2.AddItem"机动车驾驶操作相关基础知识"Combo2.AddItem"安全行车常识"Combo2.AddItem"职业道德和文明驾驶常识"Combo2.AddItem"紧急情况下避险常识"ElseIf Trim(Combo1.Text)="难度"ThenCombo2.AddItem"适中"Combo2.AddItem"容易"Combo2.AddItem"难"ElseIf Trim(Combo1.Text)="试题类型"ThenCombo2.AddItem"单选题"Combo2.AddItem"判断题"End IfEnd SubPrivate Sub Command1_Click()If Trim(Combo1.Text)=""ThenCall LoadGrid(MSHFlexGrid1,"select*from试题信息")ElseIf Trim(Combo1.Text)="题号"ThenCall LoadGrid(MSHFlexGrid1,"select*from试题信息where题号="& Combo2.Text&"")ElseCall LoadGrid(MSHFlexGrid1,"select*from试题信息where"& Combo1.Text&"like'%"&Combo2.Text&"%'")End IfEnd SubPrivate Sub Command2_Click()frmStInfo.TemID=""frmStInfo.Show1Command1_ClickEnd SubPrivate Sub Command3_Click()If Trim(Label2.Caption)=""ThenMsgBox"请选择记录"Exit SubEnd IffrmStInfo.TemID=Trim(Label2.Caption)frmStInfo.Show1Command1_ClickEnd SubPrivate Sub Command4_Click()If Trim(Label2.Caption)=""ThenMsgBox"请选择记录"Exit SubEnd IfWith MSHFlexGrid1If MsgBox("真的删除记录吗?题号:"&Label2.Caption,vbYesNo,"提示")=vbNo Then Exit SubCn.Execute"delete from试题信息where题号='"&Label2.Caption&"'" MsgBox"删除成功!"Label2.Caption=""End WithCommand1_ClickEnd SubPrivate Sub Command5_Click()Unload MeEnd SubPrivate Sub Form_Load()'ConnectDataCommand1_ClickEnd SubPrivate Sub MSHFlexGrid1_Click()With MSHFlexGrid1Label2.Caption=Trim(.TextMatrix(.Row,0))End WithEnd Sub11.试题管理界面frmStInfo.frmPublic TemID As StringDim isImg As BooleanPrivate Sub Combo1_Click(Index As Integer)If Index=4ThenIf Trim(Combo1(Index).Text)="判断题"ThenPicture2.Visible=TruePicture1.Visible=FalseElsePicture1.Visible=TruePicture2.Visible=FalseEnd IfEnd IfIf Index=1ThenIf Trim(Combo1(1).Text)="科目一"ThenCombo1(2).ClearCombo1(2).AddItem"道路交通安全法律法规和规章"Combo1(2).AddItem"道路交通信号"Combo1(2).AddItem"安全行车文明驾驶基础知识"Combo1(2).AddItem"机动车驾驶操作相关基础知识"ElseCombo1(2).ClearCombo1(2).AddItem"安全行车常识"Combo1(2).AddItem"职业道德和文明驾驶常识"Combo1(2).AddItem"紧急情况下避险常识"End IfEnd IfEnd SubPrivate Sub Command1_Click()For i=0To4If Trim(Combo1(i).Text)=""Then MsgBox Label1(i).Caption&"不能为空!":Exit SubNext iIf Trim(Text1(5).Text)=""Then MsgBox"试题内容不能为空!":Exit SubIf Trim(Text1(10).Text)=""Then MsgBox"答案不能为空":Exit SubDim rst As New ADODB.RecordsetIf rst.State Then rst.Closerst.Open"select*from试题信息where题号='"&Trim(Combo1(0).Text)&"'",Cn, adOpenStatic,adLockOptimisticIf rst.EOF Then rst.AddNewFor i=0To4rst(i).Value=Trim(Combo1(i).Text)Next iIf Trim(Combo1(4).Text)="判断题"Thenrst(5).Value=Trim(Text1(5).Text)rst(10).Value=Trim(Text1(10).Text)ElseFor i=5To10rst(i).Value=Trim(Text1(i).Text)NextIf isImg=True ThenDim StmPic As ADODB.Stream'保存你所选择的文件Set StmPic=New ADODB.StreamStmPic.Type=adTypeBinary'指定流是二进制类型StmPic.Open'将数据获取到Stream对象中StmPic.LoadFromFile(App.Path&"\temp.jpg")'将选择的文件加载到打开的StmPic中rst.Fields("图片").Value=StmPic.Read'从StmPic对象中读取数据StmPic.CloseEnd Ifrst.UpdateMsgBox"操作成功!",,"提示"Unload MeEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()On Error GoTo ErrCommonDialog1.ShowOpenmFso.CopyFile CommonDialog1.FileName,App.Path&"\temp.jpg",TrueImage1.Picture=LoadPicture(App.Path&"\temp.jpg")Picture3.RefreshPicture3.PaintPicture Image1.Picture,Picture3.ScaleTop, Picture3.ScaleLeft,Picture3.ScaleWidth,Picture3.ScaleHeight,0,0,Image1.Width, Image1.HeightisImg=TrueExit SubisImg=FalsePicture1.ClsEnd SubPrivate Sub Form_Load()Dim rst As New ADODB.RecordsetisImg=FalseIf TemID=""ThenCombo1(0).Text="1"If rst.State Then rst.Closerst.Open"select max(题号)from试题信息",Cn,adOpenStatic,adLockReadOnly If Not rst.EOF Then If Not IsNull(rst(0))Then Combo1(0).Text=Val(rst(0))+1 ElseCombo1(0).Text=TemIDCombo1(0).Locked=TrueIf rst.State Then rst.Closerst.Open"select*from试题信息where题号='"&TemID&"'",Cn, adOpenStatic,adLockOptimisticIf Not rst.EOF ThenFor i=0To4Combo1(i).Text=Trim(rst(i))Next iIf Trim(Combo1(4).Text)="判断题"ThenText1(5).Text=Trim(rst(5))Text1(10).Text=Trim(rst(10))ElseFor i=5To10Text1(i).Text=Trim(rst(i))NextEnd IfIf Not IsNull(rst!图片)ThenDim StmPic As ADODB.StreamSet StmPic=New ADODB.StreamWith StmPic.Type=adTypeBinary.Open.Write rst.Fields("图片")'写入数据库中的数据至Stream中.SaveToFile App.Path&"\temp.jpg",adSaveCreateOverWrite '将Stream中数据写入临时文件中.CloseisImg=TrueImage1.Picture=LoadPicture(App.Path&"\temp.jpg")Picture3.RefreshPicture3.PaintPicture Image1.Picture,Picture3.ScaleTop, Picture3.ScaleLeft,Picture3.ScaleWidth,Picture3.ScaleHeight,0,0,Image1.Width, Image1.HeightEnd WithEnd IfEnd IfEnd IfEnd SubPrivate Sub Option1_Click(Index As Integer)Text1(10).Text=Trim(Label1(Index).Caption)End SubPrivate Sub Option2_Click(Index As Integer)Text1(10).Text=Trim(Option2(Index).Caption)End Sub12.训练界面frmKs.frmPrivate Sub moduleTypeChoose()''选择考试类型For i=0To8If Option1(i).Value=True ThenSelect Case iCase0,1ksKm=Trim(Option1(i).Caption)ksMk=""Case2,3,4,5ksKm="科目一"ksMk=Trim(Option1(i).Caption)Case6,7,8ksKm="科目四"ksMk=Trim(Option1(i).Caption)End SelectEnd IfNextEnd SubPrivate Sub Command1_Click()''考试Call moduleTypeChoose'生成试题Call ksCsIf LoadSt=False Then MsgBox"试题不够!":Exit SubfrmTest.Show1End SubPublic Function LoadSt()As Boolean'加载试题Dim rst As New ADODB.RecordsetDim strSql As StringDim Nd(2)As StringNd(0)="难"Nd(1)="适中"Nd(2)="容易"LoadSt=TrueIf rst.State Then rst.Closerst.Open"select*from考生考试信息where用户账号='"&UserID&"'",Cn, adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenIf MsgBox("你已经考试过,是否重新考试?",vbYesNo)=vbNo ThenLoadSt=FalseExit FunctionEnd IfEnd IfCn.Execute"delete from考生考试信息where用户账号='"&UserID&"'"Cn.Execute"delete from考生成绩信息where用户账号='"&UserID&"'"If ksMk=""Then'科目For i=2To0Step-1strSql="select top"&ksInfo.pdtNdSum(i)&"*from试题信息where科目='"&ksKm&"'and试题类型='判断题'and难度='"&Nd(i)&"'order by newid()"If rst.State Then rst.Closerst.Open strSql,Cn,adOpenStatic,adLockReadOnlyWhile Not rst.EOFCn.Execute"insert into考生考试信息(用户账号,用户姓名,试卷名称,题号)values('"&UserID&"','"&UserName&"','"&ksInfo.ksName&"','"&Val(rst!题号) &"')"rst.MoveNextWendrst.CloseNextFor i=2To0Step-1strSql="select top"&ksInfo.dstNdSum(i)&"*from试题信息where科目='"&ksKm&"'and试题类型='单选题'and难度='"&Nd(i)&"'order by newid()"If rst.State Then rst.Closerst.Open strSql,Cn,adOpenStatic,adLockReadOnlyWhile Not rst.EOFCn.Execute"insert into考生考试信息(用户账号,用户姓名,试卷名称,题号)values('"&UserID&"','"&UserName&"','"&ksInfo.ksName&"','"&Val(rst!题号) &"')"rst.MoveNextWendrst.CloseNextElse'模块For i=2To0Step-1strSql="select top"&ksInfo.pdtNdSum(i)&"*from试题信息where模块='"&ksMk&"'and试题类型='判断题'and难度='"&Nd(i)&"'order by newid()"If rst.State Then rst.Closerst.Open strSql,Cn,adOpenStatic,adLockReadOnlyWhile Not rst.EOFCn.Execute"insert into考生考试信息(用户账号,用户姓名,试卷名称,题号)values('"&UserID&"','"&UserName&"','"&ksInfo.ksName&"','"&Val(rst!题号) &"')"rst.MoveNextWendrst.CloseNextFor i=2To0Step-1strSql="select top"&ksInfo.dstNdSum(i)&"*from试题信息where模块='"&ksMk&"'and试题类型='单选题'and难度='"&Nd(i)&"'order by newid()"If rst.State Then rst.Closerst.Open strSql,Cn,adOpenStatic,adLockReadOnlyWhile Not rst.EOFCn.Execute"insert into考生考试信息(用户账号,用户姓名,试卷名称,题号)values('"&UserID&"','"&UserName&"','"&ksInfo.ksName&"','"&Val(rst!题号) &"')"rst.MoveNextWendrst.CloseNextEnd IfEnd FunctionPublic Sub ksCs()'考试参数Dim rst As New ADODB.RecordsetIf rst.State Then rst.Closerst.Open"select*from试卷参数",Cn,adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenksInfo.ksName=Trim(rst(0))ksInfo.ksTime=Trim(rst!考试时间)ksInfo.pdtSum=Trim(rst!判断题题数)If Val(rst!判断题题数)>0Then ksInfo.pdtValue=Val(rst!判断题总分)/Val(rst!判断题题数)ksInfo.pdtNdSum(0)=Val(rst!判断题难)ksInfo.pdtNdSum(1)=Val(rst!判断题适中)ksInfo.pdtNdSum(2)=Val(rst!判断题容易)ksInfo.dstSum=Trim(rst!单选题题数)If Val(rst!单选题题数)>0Then ksInfo.dstValue=Val(rst!单选题总分)/Val(rst!单选题题数)ksInfo.dstNdSum(0)=Val(rst!单选题难)ksInfo.dstNdSum(1)=Val(rst!单选题适中)ksInfo.dstNdSum(2)=Val(rst!单选题容易)ElseMsgBox"无试卷参数,请设置!"Exit SubEnd IfEnd SubPrivate Sub Command2_Click()'成绩查询Dim rst As New ADODB.Recordsetrst.Open"select成绩from考生成绩信息where用户账号='"&UserID&"'",Cn, adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenIf Not IsNull(rst(0))Then MsgBox"你的成绩为:"&Trim(rst(0))End IfEnd SubPrivate Sub Command3_Click()''错题查看frmfindCt.Show1End SubPrivate Sub Command4_Click()Unload MeEnd Sub''Private Sub Form_Load()''UserID="1001"''UserName="张会"'Call ConnectData'End SubPrivate Sub Command5_Click()frmErrPractise.Show1End SubPrivate Sub Command6_Click()Call moduleTypeChoosefrmOrderPractise.Show1End Sub13.模拟考试界面frmTest.frmDim rs1As New ADODB.RecordsetDim nTime As IntegerDim SyTime As IntegerPrivate Sub Command1_Click()'提交''rs1.MoveFirstWhile Not rs1.EOFDim titleID As IntegerDim titleAnswer As StringIf Not(IsNull(rs1(6))Or IsNull(rs1(5)))ThentitleID=Val(rs1(4))titleAnswer=Trim(rs1(5))Dim rsErr As New ADODB.RecordsetIf rsErr.State Then rsErr.ClosersErr.Open"select*from考生错题表where用户账号='"&UserID&"'and 题号='"&titleID&"'",Cn,adOpenStatic,adLockReadOnlyIf Val(rs1(6))=0Then'错误If rsErr.EOF ThenCn.Execute"insert into考生错题表(用户账号,用户姓名,题号,用户答案)values('"&UserID&"','"&UserName&"','"&titleID&"','"&titleAnswer&"')"ElseCn.Execute"update考生错题表set用户答案='"&titleAnswer&"' where用户账号='"&UserID&"'and题号='"&titleID&"'"End IfElse'正确If Not rsErr.EOF ThenCn.Execute"delete from考生错题表where用户账号='"&UserID &"'and题号='"&titleID&"'"End IfEnd IfEnd Ifrs1.MoveNextWendDim rst As New ADODB.RecordsetDim nCj As Integerrst.Open"select sum(得分)from考生考试信息where用户账号='"&UserID&"'",Cn, adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenCn.Execute"delete from考生成绩信息where用户账号='"&UserID&"'"If Not IsNull(rst(0))Then nCj=Trim(rst(0))End IfIf rst.State Then rst.Closerst.Open"select*from考生成绩信息where用户账号='"&UserID&"'",Cn, adOpenStatic,adLockOptimisticrst.AddNewrst(1).Value=Format(Now,"yyyy-MM-dd hh:mm:ss") rst(2).Value=ksInfo.ksNamerst(3).Value=UserIDrst(4).Value=UserNamerst(5).Value=nCjrst.UpdateMsgBox"此次考生成绩为"&nCjUnload MeEnd SubPrivate Sub Command2_Click()''提交If Trim(Text1(5).Text)=""ThenMsgBox"无答案,不能提交!"Exit SubElseIf Trim(Text1(5).Text)=Trim(Text4.Text)Then rs1!用户答案=Trim(Text1(5).Text)If Trim(Text3.Text)="单选题"Thenrs1!得分=ksInfo.pdtValueElsers1!得分=ksInfo.dstValueEnd IfElsers1!用户答案=Trim(Text1(5).Text)rs1!得分=0End IfCommand5_ClickEnd IfEnd SubPrivate Sub Command3_Click()'<<< rs1.MoveFirstCall loadDataEnd SubPrivate Sub Command4_Click()'< rs1.MovePreviousIf rs1.BOF ThenMsgBox"已到第1题!"rs1.MoveFirstEnd IfCall loadDataEnd SubPrivate Sub Command5_Click()'> rs1.MoveNextIf rs1.EOF ThenMsgBox"已到最后1题!"rs1.MoveLastEnd IfCall loadDataEnd SubPrivate Sub Command6_Click()'>>> rs1.MoveLastCall loadDataEnd SubPrivate Sub Command7_Click() Unload MeEnd SubPrivate Sub Form_Load()'text1(nTime=0SyTime=ksInfo.ksTime-1Text1(1).Text=UserIDText1(2).Text=UserNameText1(3).Text=ksInfo.ksNameIf rs1.State Then rs1.Closers1.Open"select*from考生考试信息where用户账号='"&UserID&"'order by流水号",Cn,adOpenStatic,adLockOptimisticIf Not rs1.EOF ThenCall loadDataElseMsgBox"无考试数据!"End IfEnd SubSub loadData()Text1(0).Text=Trim(rs1(0))Text1(4).Text=Trim(rs1(4))Text1(5).Text=""If Not IsNull(rs1(5))Then Text1(5).Text=Trim(rs1(5))Dim rst As New ADODB.Recordsetrst.Open"select*from试题信息where题号='"&Val(Text1(4).Text)&"'",Cn, adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenText2.Text=Trim(rst!试题内容)Text3.Text=Trim(rst!试题类型)Text4rs1.Text=Trim(rst!难度)Text4.Text=Trim(rst!答案)If Trim(rst!试题类型)="单选题"ThenPicture1.Visible=TruePicture2.Visible=FalseFor i=6To9Text1(i).Text=Trim(rst(i))Option1(i).Value=FalseNext iElsePicture1.Visible=FalsePicture2.Visible=TrueOption2(0).Value=FalseOption2(1).Value=FalseEnd IfPicture3.ClsPicture3.RefreshIf Not IsNull(rst!图片)ThenDim StmPic As ADODB.StreamSet StmPic=New ADODB.StreamWith StmPic.Type=adTypeBinary.Open.Write rst.Fields("图片")'写入数据库中的数据至Stream中.SaveToFile App.Path&"\temp.jpg",adSaveCreateOverWrite '将Stream中数据写入临时文件中.CloseisImg=TrueImage1.Picture=LoadPicture(App.Path&"\temp.jpg")Picture3.RefreshPicture3.PaintPicture Image1.Picture,Picture3.ScaleTop, Picture3.ScaleLeft,Picture3.ScaleWidth,Picture3.ScaleHeight,0,0,Image1.Width, Image1.HeightEnd WithEnd IfEnd IfEnd SubPrivate Sub Option1_Click(Index As Integer)Text1(5).Text=Trim(Label1(Index).Caption)End SubPrivate Sub Option2_Click(Index As Integer)Text1(5).Text=Trim(Option2(Index).Caption)End SubPrivate Sub Timer1_Timer()nTime=nTime+1If nTime=60ThennTime=0SyTime=SyTime-1End IfLabel1(0).Caption=SyTime&":"&60-nTimeIf SyTime=0And nTime=59Then'自动交卷Command1_ClickEnd IfEnd Sub14.错题练习界面frmErrpractise.frmDim rs1As New ADODB.RecordsetPrivate Sub Form_Load()If rs1.State Then rs1.Closers1.Open"select*from考生错题表where用户账号='"&UserID&"'order by newid()",Cn,adOpenStatic,adLockOptimisticIf Not rs1.EOF ThenCall load_error_testEnd IfEnd SubPrivate Sub Command1_Click() Unload MeEnd SubPrivate Sub Command3_Click() If Not rs1.EOF Then'显示第一题Text1(5).Text=""rs1.MoveFirstCall load_error_testEnd IfEnd SubPrivate Sub Command4_Click() If Not rs1.EOF Then'显示上一题Text1(5).Text=""rs1.MovePreviousIf rs1.BOF ThenMsgBox"已到第1题!"rs1.MoveFirstEnd IfCall load_error_testEnd IfEnd SubPrivate Sub Command5_Click() If Not rs1.EOF Then'显示下一题Text1(5).Text=""rs1.MoveNextIf rs1.EOF ThenMsgBox"已到最后1题!"rs1.MoveLastEnd IfCall load_error_testEnd IfEnd SubPrivate Sub Command6_Click()If Not rs1.EOF Then'显示最后一题Text1(5).Text=""rs1.MoveLastCall load_error_testEnd IfEnd SubPrivate Sub Command7_Click()If Not rs1.EOF ThenDim rst As New ADODB.Recordsetrst.Open"select*from试题信息where题号='"&Val(rs1(2))&"'",Cn, adOpenStatic,adLockReadOnlyIf Not rst.EOF ThenText1(5).Text=Trim(rst(10))End IfEnd IfEnd SubPrivate Sub load_error_test()Dim rst As New ADODB.Recordsetrst.Open"select*from试题信息where题号='"&Val(rs1(2))&"'",Cn,adOpenStatic, adLockReadOnlyIf Not rst.EOF ThenText7.Text=Trim(rst!试题内容)Text6.Text=Trim(rst!试题类型)。