下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 VB程序代码

VB程序代码.doc

VB程序代码

太多的感受
2017-09-27 0人阅读 举报 0 0 暂无简介

简介:本文档为《VB程序代码doc》,可适用于综合领域

VB程序代码PrivateSubCommandClick()TextFont="黑体"TextFont="隶书"EndSubPrivateSubCommandClick()TextForeColor=vbRedTextBackColor=vbBlueEndSubPrivateSubCommandClick()EndEndSubPrivateSubCommandMouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)formBackColor=vbGreenEndSubPrivateSubCommandMouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)formBackColor=vbRedEndSubPrivateSubFormMouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)TextText="在窗体上抬起了鼠标"EndSubPrivateSubFormMouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)TextText="在窗体上anxia了鼠标"EndSubPrivateSubCommandClick()FormPrint"hhggg"EndSubPrivateSubCommandClick()FormClsEndSubPrivateSubCommandClick()TextText=""TextText=""TextText=""TextSetFocusTextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubCommandClick()EndEndSubPrivateSubTextChange()TextText=TextTextTextText=TextTextEndSubDimxAsSinglePrivateSubCommandClick()x=xTextFontSize=xEndSubPrivateSubCommandClick()Ifx<ThenTextFontSize=ElseIfx>=Thenx=xTextFontSize=on=DatePart("yyyy",Now)LabelCaption=DatePart("m",Now)LabelCaption=DatePart("d",Now)LabelCaption=Int(DatePart("w",Now))LabelCaption=TimeEndSubPrivateSubFormLoad()LabelCaption=Year(Now)LabelCaption=Month(Now)LabelCaption=Day(Now)LabelCaption=Weekday(Now)LabelCaption=TimeEndSub代码如下DimaAsStringDimbAsIntegerDimdAsStringPrivateSubTextChange()a=UCase(Trim(TextText))d="THEQUICKBROWNFOXJUMPSOVERALAZYDOG"b=InStr(d,a)TextText=a"firstoccursinposition"bEndSubPOptionExplicitDimaAsSingle,bAsSingle,cAsSinglePrivateSubCommandClick()a=Val(TextText)b=Val(TextText)c=Val(TextText)TextText=(abc)EndSubPrivateSubCommandClick()TextText=""TextText=""TextText=""TextText=""TextSetFocusEndSubPrivateSubCommandClick()EndEndSubPrivateSubTextgotfocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextgotfocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextgotfocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextchange()TextText=""EndSubPrivateSubTextchange()TextText=""EndSubPrivateSubTextchange()TextText=""EndSubPOptionExplicitPrivateSubCommandClick()DimcharAsString*char=TextTextTextText=TextTextSpace()charSpace()Str(Asc(char))vbCrLfTextSetFocusTextSelStart=TextSelLength=Len(TextText)EndSubPPrivateSubCommandClick()DimaAsSingle,bAsSingle,cAsSingle,pAsSingle,sAsSinglea=Val(TextText)b=Val(TextText)c=Val(TextText)p=(abc)s=Sqr(p*(pa)*(pb)*(pc))LabelCaption=Format(s,"")TextSetFocusTextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubFormLoad()EndSubPrivateSubTextChange()LabelCaption=""EndSubPrivateSubTextChange()LabelCaption=""EndSubPrivateSubTextChange()LabelCaption=""EndSubPOptionExplicitPrivateSubCommandClick()MsgBox"吧vvghjjk"EndSubPrivateSubCommandClick()MsgBox"踢死信息"vbCrLf"huanhangtisi"EndSubPrivateSubCommandClick()MsgBox"踢死信息",,"mmjk"EndSubPrivateSubCommandClick()MsgBox"踢死信息",,"kll"EndSubPrivateSubCommandClick()MsgBox"踢死信息",,"klh"EndSubPrivateSubCommandClick()MsgBox"踢死信息",,"klh"EndSubPOptionExplicitDimxAsInteger,yAsInteger,zAsIntegerPrivateSubFormActivate()x=:y=Print"ngfgh"PrintxyPrintz=xy关系表达式Print""表达式用分号作为分隔符时则按紧凑格式输出数据Print"",–‘表达式用逗号作为分隔符时则按分区格式显示数据项Print"",没执行一次print方法时自动换行如要在同一行输出则可以在末尾加分号或逗号CurrentX=决定下一次打印的水平或垂直坐标CurrentX=Print""PrintPrint省略表达式则输出一个空行或取消前面print的逗号或分号的作用Print"",PrintFormShow若在formload事件中必须首先使用show或把窗体对象图片框的autoredraw属性设置为true否则print不起作用Print"ghjgfg"Print"",Print""PrintEndSubPrivateSubFormLoad()FormPrint"jggfhj"EndSubPPrivateSubFormActivate()Print"ghfdggf"Print"gffd"Tab()"fgd"'第二个输出项在列输出Print"gfgdd"Tab"fghjk"'tab函数无参数第二项在第二个打印去输出Print"ddffg"Tab()"fghh"'n小雨当前打印位置第二项在下一行输出PrintTab()"ghfl"'n小于在第一列输出Print"lkkj"Spc()"gfdds"'跳过个空格EndSubPPrivateSubCommandClick()DimhAsInteger,fAsInteger,xAsInteger,yAsIntegerh=Val(TextText)f=Val(TextText)x=(*hf)y=(f*h)LabelCaption=LabelCaptionStr(x)"只"LabelCaption=LabelCaptionStr(y)"只"EndSubPrivateSubTextgotfocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextgotfocus()TextSelStart=TextSelLength=Len(TextText)EndSubPPrivateSubCommandClick()DimAAsInteger,BAsIntegerRandomizeA=Val(TextText)B=Val(TextText)LabelCaption=Str(Int(Rnd*(BA)A))'产生AB区间的随机整数LabelCaption=Str(Int(Rnd*(BA)A))LabelCaption=Str(Int(Rnd*(BA)A))EndSubPrivateSubTextGotFocus()TextSelStart='在TEXT获得焦点时选中其中的文本TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPPrivateSubFormLoad()DimMAsLong,TEMPAsStringShowM=^TEMP=Str(M)'将M转换成字符串LabelCaption="^"LabelCaption=LabelCaptionTEMPCurrentX='定义窗体当前打印位置的XY坐标CurrentY=Print"总共有"Len(Trim(TEMP))"位"'使用TRIM去除空格EndSubPPrivateSubCommandClick()DimPhoneNOAsString,nAsIntegerDimtmpAsString,numAsLongPhoneNO=Trim(TextText)n=Len(PhoneNO)tmp=Right(PhoneNO,)num=Val(tmp)PhoneNO=Left(PhoneNO,n)""Trim(Str(num))TextText=PhoneNOEndSubOptionExplicitDimaAsSingle,bAsSinglePrivateSubCommandClick()a=Val(TextText)b=Val(TextText)TextText=a*bEndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=当焦点在该位置时,点ENTER相当于点击鼠标EndSubPrivateSubCommandClick()EndEndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubDimAAsSingle,BAsSingle,CAsSingle'定义ABC变量PrivateSubCommandClick()A=Val(TText)'给变量赋值B=Val(TText)C=Val(TText)TRESULTText=A*B*(C)'计算应付款TSetFocusEndSubPrivateSubCommandClick()TRESULTText=""'清除应付款TSetFocus'将焦点定位在“折扣”一栏选中“折扣”中的内容TSelStart=TSelLength=Len(TRESULTText)EndSubPrivateSubCommandClick()EndEndSubDimAAsSingle,BAsSingle,CAsSingleConstPI='定义变量PrivateSubCommandClick()A=Val(TextText)*PIB=Abs(Sin(A))'分别计算sin,cosC=Abs(Cos(A))TextText=TextTextSpace()Format(A,"")Space()Format(B,"")Space()Format(C,"")vbCrLf'每次计算结果赋在上次计算结果之后显示于带垂直滚动条的文本框中所有结果保留位小数TextSetFocus'每次计算完选中输入的文本一边继续输入TextSelStart=TextSelLength=Len(TextText)EndSubDimaAsSingle,bAsSingle,cAsSinglePrivateSubFormClick()a=InputBox("请输入小时")b=InputBox("请输入分")c=InputBox("请输入秒")Printa"小时"b"分"c"秒="a*b*c"秒"EndSubOptionExplicitDimaAsSingle,bAsSingle,cAsSingle,dAsSingle,eAsSingle,fAsSinglePrivateSubCommandClick()a=Val(TextText)b=Val(TextText)c=Val(TextText)d=Val(TextText)e=Val(TextText)f=Val(TextText)LabelCaption="X="(c*eb*f)(a*eb*d)LabelCaption="Y="(a*fd*c)(a*eb*d)EndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=设置ENTER键EndSubPrivateSubCommandClick()TextText=""TextText=""TextText=""清除TextText=""TextText=""TextText=""LabelCaption=""LabelCaption=""EndSubPrivateSubTextGotFocus()TextSelStart=获得焦点是,选中文本TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart='将焦点设置在text,雪中所有内容TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPDimxAsSingle,yAsSinglePrivateSubCommandClick()x=Val(TextText)Ifx<=Theny=Abs(x)Elsey=Log(x)LabelCaption=yTextSetFocusTextSelStart='将焦点设置在text,雪中所有内容TextSelLength=Len(TextText)EndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=EndSubPDimxAsSingle,yAsSinglePrivateSubCommandClick()x=Val(TextText)y=Val(TextText)Ifx=Ory=ThenPrint"ngj":ExitSubIfx>ThenIfy>ThenPrint"在第一象限"ElsePrint"在第四象限"ElseIfy>ThenPrint"在第二象限"ElsePrint"在第三象限"EndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubDimxAsSingle,yAsSinglePrivateSubCommandClick()x=Val(TextText)y=Val(TextText)Ifx=Ory=ThenPrint"该点不在任何象限内"ElseIfx>Andy>ThenPrint"在第一象限"ElseIfx>Andy<ThenPrint"在第四象限"ElseIfx<Andy<ThenPrint"在第三象限"ElsePrint"在第二象限"EndIfEndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPOptionExplicitDimcAsSinglePrivateSubCommandClick()c=*(Val(TextText))TextText=Format(c,"")Ifc>ThenLabelCaption="hot"ElseIfc>Andc<=ThenLabelCaption="warm"ElseIfc>Andc<=ThenLabelCaption="roomtemperature"ElseIfc>Andc<=ThenLabelCaption="cool"ElseIfc>Andc<=ThenLabelCaption="cold"ElseLabelCaption="freezing"EndIfEndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubDimcAsSinglePrivateSubCommandClick()c=*(Val(TextText))TextText=Format(c,"")Ifc>ThenLabelCaption="hot"ElseIfc>ThenLabelCaption="warm"ElseIfc>ThenLabelCaption="roomtemperature"ElseIfc>ThenLabelCaption="cool"ElseIfc>ThenLabelCaption="cold"ElseLabelCaption="freezing"EndIfEndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPOptionExplicitDimxAsSingle,yAsSinglePrivateSubCommandClick()x=Val(TextText)SelectCasexCaseIs<y=Exp(x)Exp(x)Casey=CaseIs>y=Log(x)Log()EndSelectTextText=Format(y,"")EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPOptionExplicitDimxAsDouble,yAsDouble,zAsDouble,aAsDoublePrivateSubCommandClick()x=Val(TextText)y=Val(TextText)z=Val(TextText)SelectCasezCaseIs<a=CaseIs<a=CaseIs<a=CaseIs<a=CaseIs<a=CaseElsea=EndSelectTextText=x*y*z*(a)EndSubPPrivateSubTextKeyUp(KeyCodeAsInteger,ShiftAsInteger)StaticiAsIntegerIfKeyCode=ThenIfUCase(TextText)="kkll"ThenLabelCaption="恭喜~您进入了本系统"ElseIfi=Ori=Theni=iLabelCaption="口令错!请重新输入"TextSelStart=TextSelLength=Len(TextText)ElseMsgBox"对不起你不能进入本系统"EndIfEndIfEndSubPOptionExplicitDimaAsDouble,bAsDouble,cAsDouble,xAsDouble,yAsDouble,dAsDoublePrivateSubCommandClick()a=Val(TextText)b=Val(TextText)c=Val(TextText)ClsCurrentX=CurrentY=Ifa=ThenIfb=ThenMsgBox"系数为零请重新输入"TextSetFocusTextSelStart=TextSelLength=Len(TextText)Elsex=cbPrint"x="Format(x,"")EndIfExitSubEndIfd=b^*a*cSelectCasedCasePrint"x=x"Format(b(*a),"")CaseIs>Print"x="Format((bSqr(d))(*a),"")CurrentX=CurrentY=Print"x="Format((bSqr(d))(*a),"")CaseIs<Print"x="Format(b(*a),"")""Format(Sqr(Abs(d))(*a),"")"i"CurrentX=CurrentY=Print"x="Format(b(*a),"")""Format(Sqr(Abs(d))(*a),"")"i"EndSelectEndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPrivateSubTextGotFocus()TextSelStart=TextSelLength=Len(TextText)EndSubPDimaAsStringPrivateSubTextChange()LabelCaption=Trim(TextText)EndSubPrivateSubCommandClick()RandomizeTextText=Int(Rnd*)TextText=Int(Rnd*)TextText=""EndSubPrivateSubCommandClick()IfLabelCaption=""ThenTextText=Val(TextText)Val(TextText)ElseIfLabelCaption=""ThenTextText=Val(TextText)Val(TextText)ElseIfLabelCaption="*"ThenTextText=Val(TextText)*Val(TextText)ElseIfLabelCaption=""ThenTextText=Val(TextText)Val(TextText)Elsea=MsgBox("运算错请重输",,"警告")TextSetFocusTextSelStart=TextSelLength=Len(TextText)EndIfEndSubPrivateSubCommandClick()SelectCaseLabelCaptionCase""IfTextText=Val(TextText)Val(TextText)ThenLabelCaption="正确"ElseLabelCaption="错误"EndIfCase""IfTextText=Val(TextText)Val(TextText)ThenLabelCaption="正确"ElseLabelCaption="错误"EndIfCase"*"IfTextText=Val(TextText)*Val(TextText)ThenLabelCaption="正确"ElseLabelCaption="错误"EndIfCase""IfTextText=Val(TextText)Val(TextText)ThenLabelCaption="正确"ElseLabelCaption="错误"EndIfCaseElsea=MsgBox("运算错请重输",,"警告")TextSetFocusTextSelStart=TextSelLength=Len(TextText)EndSelectEndSubPrivateSubCommandClick()EndEndSub黎稳DimaAsInteger,bAsInteger,cAsInteger定义变量PrivateSubTextClick()TextText=InputBox("请输入一个整数")‘用InputBox()函数输给文本框text一个整数EndSubPrivateSubCommandClick()a=Val(TextText)Mod‘同时除以取余数b=Val(TextText)Modc=Val(TextText)ModIfa=Andb=Andc=ThenLabelCaption="能同时被整除"ElseLabelCaption="不能整除"‘判断text中的整数能否被整除能整除时显示“能同时被整除”否则显示“不能整除”EndSubOptionExplicitDimaAsSingle,bAsSingle,cAsSingle,maxAsSingle,minAsSinglePrivateSubFormLoad()ShowTextText=InputBox("ii")TextText=InputBox("ii")TextText=InputBox("ii")a=Val(TextText)b=Val(TextText)c=Val(TextText)max=aIfb>maxThenmax=bIfc>maxThenmax=cPrint"最大值:"maxmin=aIfb<minThenmin=bIfc<minThenmin=cPrint"最小值:"minEndSubDimaAsSingle,bAsSinglePrivateSubCommandClick()LabelCaption="y="a=Val(Trim(TextText))b=Val(Trim(TextText))Ifa>Andb>ThenLabelCaption=Str(Log(a)Log(b))ElseIfa>Andb<=ThenLabelCaption=Str(Sin(a)Sin(b))ElseLabelCaption=Str(Sin(a)Cos(b))EndIfEndSubDimaAsSinglePrivateSubCommandClick()a=Val(TextText)Ifa<=ThenTextText=""ElseIfa>Anda<=ThenTextText=(a)*ElseTextText=(a)*EndIfEndSubDimaAsSingle,bAsIntegerPrivateSubCommandClick()a=Val(TextText)Ifa>Ora<Thenb=MsgBox("成绩无效",,"学生成绩")SelectCaseaCaseIs>=LabelCaption="优"CaseIs>=LabelCaption="良"CaseIs>=LabelCaption="中"CaseIs>=LabelCaption="及格"CaseIs>=LabelCaption="不及格"EndSelectEndSubDimaAsInteger,bAsInteger,cAsInteger,dAsSingle,eAsIntegerPrivateSubCommandClick()a=Val(TextText)'text中输入月份SelectCaseaCase,,,'月份为个月的天数为TextText=Case,,,,,,'月份为个月的天数为TextText=CaseElsec=Val(TextText)Mod'text中的年份分别除以d=Val(TextText)Mode=Val(TextText)ModIfc=Andd<>Then'判断年份能否被整除但不能被一百整除'条件满足则月份天数为天。或者能否被整除条件满足则月份为天。否则为天TextText=ElseIfe=ThenTextText=ElseTextText=EndIfEndSelectEndSub小学生算术题DiminsignAsInteger,dAsString,aAsInteger,bAsInteger,cAsInteger'定义变量PrivateSubFormLoad()RandomizeLabelCaption=Int(Rnd*)'在labellabel中产生随机数LabelCaption=Int(Rnd*)insign=Int(Rnd*)Mod'对变量insign取余数SelectCaseinsign'当insign分别等于时LabelCaption分别为*且LabelCaption自动生成"="CaseLabelCaption="":LabelCaption="="CaseLabelCaption="":LabelCaption="="CaseLabelCaption="*":LabelCaption="="EndSelectEndSubPrivateSubTextKeyDown(KeyCodeAsInteger,ShiftAsInteger)IfKeyCode=Then'如果按下回车键d=Val(Trim(TextText))'在text中输入一个整数SelectCaseinsignCaseIfd=Val(LabelCaption)Val(LabelCaption)Then'labelcaption为时比较text中的值与表达式的值LabelCaption="很好"d=MsgBox("要继续练习吗",)'如果text的值与表达式的值相等则用MsgBox函数提示信息问―要继续练习吗,‖由回答结果确定与否决定退出练习或继续练习继续时再次生成新的表达式Text置空LabelCaption=Int(Rnd*)LabelCaption=Int(Rnd*)ElseLabelCaption="很遗憾~"'若输入与准确值不相等Label中写入―很遗憾~‖并选中Text的所有文本等待学生新的输入。EndIfTextSetFocusTextSelStart=TextSelLength=Len(TextText)CaseIfd=Val(LabelCaption)Val(LabelCaption)Then'当labelcaption为时比较text中的值与表达式的值LabelCaption="很好"d=MsgBox("要继续练习吗",)'如果text的值与表达式的值相等则用MsgBox函数提示信息问―要继续练习吗,‖由回答结果确定与否决定退出练习或继续练习继续时再次生成新的表达式Text置空LabelCaption=Int(Rnd*)LabelCaption=Int(Rnd*)ElseLabelCaption="很遗憾~"'若输入与准确值不相等Label中写入―很遗憾~‖并选中Text的所有文本等待学生新的输入。EndIfTextSetFocusTextSelStart=TextSelLength=Len(TextText)CaseIfd=Val(LabelCaption)*Val(LabelCaption)Then'当labelcaption为时比较text中的值与表达式的值LabelCaption="很好"d=MsgBox("要继续练习吗",)'如果text的值与表达式的值相等则用MsgBox函数提示信息问―要继续练习吗,‖由回答结果确定与否决定退出练习或继续练习继续时再次生成新的表达式Text置空LabelCaption=Int(Rnd*)LabelCaption=Int(Rnd*)ElseLabelCaption="很遗憾~"'若输入与准确值不相等Label中写入―很遗憾~‖并选中Text的所有文本等待学生新的输入。EndIfTextSetFocusTextSelStart=TextSelLength=Len(TextText)EndSelectEndIfEndSubDimaAsStringPrivateSubFormLoad()TextText=""EndSubPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)StaticiAsIntegerIfKeyCode=ThenIfTextText="liwen"ThenShell"c:winntsystemformexe",vbNormalFocusElseIfi=Ori=Theni=iFormCaption="口令错请重新输入"Elsea=MsgBox("对不起您不能使用本系统",)EndEndIfEndIfEndSubDimbAsIntegerPrivateSubCommandKeyDown(KeyCodeAsInteger,ShiftAsInteger)KeyCode=EndSubPrivateSubCommandClick()StaticaAsIntegerIfTextText="li"Thenb=MsgBox("欢迎")ElseIfa=Ora=Thena=aFormCaption="口令错"ElseMsgBox"对不起"EndIfEndSubOptionBasePrivateSubCommandClick()Dimc()AsInteger,bAsInteger,gAsStringTextText=""b=Val(InputBox("请输入总人数","",""))'输入总人数ReDimc(b)Callli(b,c())'调用过程liFori=TobTextText=TextTextStr(c(i))'成绩显示在Text中NextiCallli(b,c(),g)'调用过程li成绩数组元素的最大、最小值并记录最大值、最小值所在的位置LabelCaption=gTextText=""Callli(b,c())'调用过程li将排序后的成绩显示在TextFori=TobTextText=TextTextStr(c(i))NextiEndSubSubli(nAsInteger,ByRefscore()AsInteger)RandomizeReDimscore(n)'过程li随机产生n个成绩Fori=Tonscore(i)=Val(Int(*Rnd))NextiEndSubSubli(nAsInteger,c()AsInteger,fAsString)DimMAXAsInteger,MINAsInteger,dAsInteger,eAsIntegerMAX=c():MIN=c()Fori=TonIfMAX<c(i)Then'排序如果max大于c(i)则将c(i)赋给maxMAX=c(i)d=iEndIfIfMIN>c(i)Then'排序如果MIN大于c(i)则将c(i)赋给MINMIN=c(i)e=iEndIfNextf="最高分为:"Str(MAX)"分""在第"Str(d)"位""最低分为:"Str(MIN)"分""在第"Str(e)"位"EndSubSubli(bAsInteger,c()AsInteger)DimtAsInteger,iAsInteger,jAsIntegerFori=TobForj=iTob'过程li排序Ifc(i)<c(j)Thent=c(i)c(i)=c(j)c(j)=tEndIfNextj,iEndSub实验六、数组应用一实验目的掌握数组基本概念数组的多种定义方法(静态、动态一维、二维)掌握数组的输入输出及数组删除释放存储空间使用多种程序设计结构对数组元素进行统计、添加、删除、排序等操作创建控件数组达到可多样化地输出数组的运行效果。通过本实验学生可以掌握数组的基本操作进一步熟悉各种结构程序设计编程技巧感受数组结合控件设计方法的技巧。二实验内容和步骤:实验内容:(两个题目)本实验的所有数据处理算法、界面风格设计及事件过程均由学生自行设计、实现。题目:随机生成上位学生的两门课程成绩(事件),完成以下功能:分别求出各门课程学生成绩的最高分、最低分和平均分(事件)求每位学生两门课程的平均分数按此分数分段统计各分数段的人数并显示(事件)题目窗体界面标题:―学生成绩统计程序,设计者姓名‖。题目:(用控件数组实现,如多个按钮多个文本框)输入N位学生(或运功员)的单门课程(或单目比赛)成绩并显示(事件)其中人数N由读入得到对数组按值从大到小排序后并显示成绩(事件)给出某成绩删除数组的该成绩记录并显示(若无显示相应信息)(事件)给出新成绩添加到成绩数组中并显示。(事件)黎稳OptionBaseDimA()AsInteger,B()AsInteger,SCORE()AsSinglePrivateSubCommandClick()TextText=""'清空TextText=""n=ReDimA(n),B(n)Fori=ToRandomizeA(i)=Int(Rnd*)'随机生成之间的个数显示在text中TextText=TextTextStr(A(i))B(i)=Int(Rnd*)'随机生成之间的个数显示在text中TextText=TextTextStr(B(i))NextiEndSubPrivateSubCommandClick()DimMAXAsInteger,MINAsInteger,AVERAsInteger,MAXAsInteger,MINAsInteger,AVERAsInteger,SUMAsInteger,SUMAsIntegerMAX=A():MIN=A():MAX=B():MIN=B():SUM=:SUM=Fori=ToIfMAX<A(i)Then'排序如果max小于A(i)则将A(i)赋给maxMAX=A(i)EndIfIfMAX<B(i)Then'排序如果max小于B(i)则将B(i)赋给maxMAX=B(i)EndIfTextText=Str(MAX)TextText=Str(MAX)IfMIN>A(i)Then'排序如果MIN小于A(i)则将A(i)赋给MINMIN=A(i)EndIfIfMIN>B(i)Then'排序如果MIN小于B(i)则将B(i)赋给MINMIN=B(i)EndIfTextText=Str(MIN)TextText=Str(MIN)SUM=SUMA(i)'累加A(i)SUM=SUMB(i)NextTextText=Str(SUM)'求课程的平均成绩TextText=Str(SUM)'求课程的平均成绩EndSubPrivateSubCommandClick()DimNUMAsSingle,NUMAsSingle,NUMAsSinglen=ReDimSCORE(n)Fori=TonSCORE(i)=(Val(A(i))Val(B(i)))TextText=TextTextStr(SCORE(i))IfSCORE(i)>=AndSCORE(i)<Then'如果分数在则NUM加NUM=NUMElseIfSCORE(i)>=AndSCORE(i)<Then'如果分数在则NUM加NUM=NUMElseNUM=NUMEndIfTextText=Str(NUM):TextText=Str(NUM):TextText=Str(NUM)'如果分数在则NUM加NextEndSubOptionBaseDimscore()AsInteger,nAsIntegerPrivateSubCommandClick()DimaAsStringn=Val(InputBox("请输入总人数","",""))ReDimscore(n)TextText=""ForI=Tonscore(I)=Val(InputBox("请输入"Str(I)"个学生的成绩","请输入成绩",""))TextText=TextTextStr(score(I))NextIEndSubPrivateSubCommandClick()ForI=TonForj=ITonIfscore(I)>score(j)Thent=score(I)score(I)=score(j)score(j)=tEndIfNextj,ITextText=""ForI=TonTextText=TextTextStr(score(I))NextIEndSubPrivateSubCommandClick()DimcAsInteger,dAsString,kAsIntegerc=Val(TextText)ForI=TonIfscore(I)=cThenk=IEndIfNextIIfk<=Ork>nThenMsgBox"没找到该分数"ElseForI=kTonscore(I)=score(I)NextITextText=""ForI=TonTextText=TextTextStr(score(I))NextIEndIfEndSubPrivateSubCommandClick()DimnumAsInteger,posAsIntegernum=Val(TextText)pos=Val(TextText)ReDimPreservescore(n)SelectCaseposCaseIs<='Pos<=,将Num插在第个位置ForI=nToStepscore(I)=score(I)'对数组的元素全部向后移动一个位置NextIscore()=num'插入CaseIs>=n'Pos,=N则将Num插在最后一个位置score(n)=num'插入CaseElse'在数组中插入ForI=nToposStepscore(I)=score(I)NextIscore(pos)=num'插入EndSelectForI=TonTextText=TextTextStr(score(I))NextIEndSub实验七、过程调用实验题目:编写一个学生(或运动员)成绩管理的应用程序要求具有以下个功能,每一个功能由自定义过程或自定义函数过程实现:随机生成上n位学生的单门课程成绩(或上n位运动员的单次比赛成绩)其中过程形式如:Sub过程名(NAsInteger,Scrore()AsInteger)虚参Score()为成绩数组N为数组元素的上界分别求出成绩数组元素的最大、最小值并记录最大值、最小值所在的位置(即对应的哪位同学(或运动员))对数组按成绩值从大到小排序其中过程形式为:Sub过程名(NAsInteger,Score()AsInteger)。实验要求:建立一个窗体窗体界面标题为:―学生(或运动员)成绩管理程序设计者姓名‖。()在窗体中调用Sub子过程产生学生(或运动员)的原始成绩将其显示在文本框或其他控件中()调用Sub过程或函数过程完成学生(或运动员)成绩的计算(即功能)操作,并显示计算结果()调用Sub过程实现成绩排序并将结果显示在文本框或其他控件中。注意:)提交实验报告(电子版和书面两种形式实验报告模板可参考数组应用)。电子版实验报告文件命名:后位学号过程调用实验doc。)提交题目的exe文件文件命名:后位学号exeOptionBasePrivateSubCommandClick()Dimc()AsInteger,bAsInteger,gAsStringTextText=""b=Val(InputBox("请输入总人数","",""))'输入总人数ReDimc(b)Callli(b,c())'调用过程liFori=TobTextText=TextTextStr(c(i))'成绩显示在Text中NextiCallli(b,c(),g)'调用过程li成绩数组元素的最大、最小值并记录最大值、最小值所在的位置LabelCaption=gTextText=""Callli(b,c())'调用过程li将排序后的成绩显示在TextFori=TobTextText=TextTextStr(c(i))NextiEndSubSubli(nAsInteger,ByRefscore()AsInteger)RandomizeReDimscore(n)'过程li随机产生n个成绩Fori=Tonscore(i)=Val(Int(*Rnd))NextiEndSubSubli(nAsInteger,c()AsInteger,fAsString)DimMAXAsInteger,MINAsInteger,dAsInteger,eAsIntegerMAX=c():MIN=c()Fori=TonIfMAX<c(i)Then'排序如果max大于c(i)则将c(i)赋给maxMAX=c(i)d=iEndIfIfMIN>c(i)Then'排序如果MIN大于c(i)则将c(i)赋给MINMIN=c(i)e=iEndIfNextf="最高分为:"Str(MAX)"分""在第"Str(d)"位""最低分为:"Str(MIN)"分""在第"Str(e)"位"EndSubSubli(bAsInteger,c()AsInteger)DimtAsInteger,iAsInteger,jAsIntegerFori=TobForj=iTob'过程li排序Ifc(i)<c(j)Thent=c(i)c(i)=c(j)c(j)=tEndIfNextj,iEndSu

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/50

VB程序代码

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利