欢迎来到天天文库
浏览记录
ID:56132415
大小:73.00 KB
页数:7页
时间:2020-06-20
《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
2、=""Text1.SetFocusEndSubPrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText3_KeyPress(KeyAsciiAsInte
3、ger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSub2.健康称PrivateSubForm_Load()Form1.Caption="健康称"Text1.Alignment=1Text2.Alignment=1Text1.MaxLength=3Text2.MaxLength=3EndSubPrivateSubCommand1_Click()DimsgAsInteger,tzAsInteger,bzAsIntegersg=Val(Text1
4、.Text)tz=Val(Text2.Text)bz=sg-105Iftz/bz>=1.1ThenLabel5.Caption="偏胖,注意节俭!"ElseIftz/bz<=0.9ThenLabel5.Caption="偏瘦,增加营养!"ElseLabel5.Caption="正常。继续保持!"EndIfEndSubPrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0:Text1.S
5、etFocusEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0:Text2.SetFocusEndSub3.最大化PrivateSubForm_Load()Command1.Left=(Form1.ScaleWidth-Command1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2Command1
6、.Caption="最大化(&L)"EndSubPrivateSubCommand1_Click()IfCommand1.Caption="最大化(&L)"ThenCommand1.Caption="还原(&B)"Form1.WindowState=2Command1.Left=(Form1.ScaleWidth-Command1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2ElseCommand1.Caption="最大化
7、(&L)"Form1.WindowState=0Command1.Left=(Form1.ScaleWidth-Command1.Width)/2Command1.Top=(Form1.ScaleHeight-Command1.Height)/2EndIfEndSub4.判断质数PrivateSubCommand1_Click()DimiAsInteger,XAsIntegerIfIsNumeric(Text1.Text)=FalseThenMsgBox"输入的不是数字,无法计算",,"desi
8、gn"Elsex=Val(Text1)n=Int(Sqr(x))Fori=2TonIfxModi=0ThenExitForNextIfi>nThenLabel3.Caption=X&"是质数"ElseLabel3.Caption=X&"不是质数"EndIfEndIfEndSub5.计算平均成绩PrivateSubForm_Load()Text2.Locked=TrueEndSubPrivateSubText1_Change(IndexAsInteger)Text2=""Text2=(Val(Te
此文档下载收益归作者所有