欢迎来到天天文库
浏览记录
ID:28100887
大小:73.00 KB
页数:7页
时间:2018-12-08
《vb上机程序设计题题解.doc》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、上机程序设计题题解1.加法器PrivateSubForm_Load()Text1.Alignment=1Text2.Alignment=1Text3.Alignment=1Text3.Locked=TrueEndSubPrivateSubCommand1_Click()Text3.Text=Str(Val(Text1.Text)+Val(Text2.Text))EndSubPrivateSubCommand2_Click()Text1.Text=""Text2.Text=""Text3.Text=""Text1.SetFocusEndSubPrivateSu
2、bText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText3_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSub2.健康称Priv
3、ateSubForm_Load()Form1.Caption="健康称"Text1.Alignment=1Text2.Alignment=1Text1.MaxLength=3Text2.MaxLength=3EndSubPrivateSubCommand1_Click()DimsgAsInteger,tzAsInteger,bzAsIntegersg=Val(Text1.Text)tz=Val(Text2.Text)bz=sg-105Iftz/bz>=1.1ThenLabel5.Caption="偏胖,注意节俭!"ElseIftz/bz<=0.9ThenLa
4、bel5.Caption="偏瘦,增加营养!"ElseLabel5.Caption="正常。继续保持!"EndIfEndSubPrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0:Text1.SetFocusEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0:Text2.SetFocusEndSub3.最大化Privat
5、eSubForm_Load()Command1.Left=(Form1.ScaleWidth-Command1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2Command1.Caption="最大化(&L)"EndSubPrivateSubCommand1_Click()IfCommand1.Caption="最大化(&L)"ThenCommand1.Caption="还原(&B)"Form1.WindowState=2Command1.Left=(Form1.ScaleWidth-Co
6、mmand1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2ElseCommand1.Caption="最大化(&L)"Form1.WindowState=0Command1.Left=(Form1.ScaleWidth-Command1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2EndIfEndSub4.判断质数PrivateSubCommand1_Click()DimiAsInteger,XAsIntegerIf
7、IsNumeric(Text1.Text)=FalseThenMsgBox"输入的不是数字,无法计算",,"design"Elsex=Val(Text1)n=Int(Sqr(x))Fori=2TonIfxModi=0ThenExitForNextIfi>nThenLabel3.Caption=X&"是质数"ElseLabel3.Caption=X&"不是质数"EndIfEndIfEndSub5.计算平均成绩PrivateSubForm_Load()Text2.Locked=TrueEndSubPrivateSubText1_Change(IndexAsInt
8、eger)Text2=""Text2=(Val(Te
此文档下载收益归作者所有