欢迎来到天天文库
浏览记录
ID:55503850
大小:80.50 KB
页数:7页
时间:2020-05-15
《上机程序设题参考(树人大学).doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、上机程序设计题题解(P116~P126)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.SetFoc
2、usEndSubPrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0EndIfEndSubPrivateSubText3_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAsci
3、i=0EndIfEndSub2.健康称PrivateSubForm_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="偏胖
4、,注意节俭!"ElseIftz/bz<=0.9ThenLabel5.Caption="偏瘦,增加营养!"ElseLabel5.Caption="正常。继续保持!"EndIfEndSubPrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0:Text1.SetFocusEndSubPrivateSubText2_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii>57ThenKeyAsci
5、i=0:Text2.SetFocusEndSub3.最大化PrivateSubForm_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.Window
6、State=2Command1.Left=(Form1.ScaleWidth-Command1.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.判断质数Priva
7、teSubCommand1_Click()DimiAsInteger,XAsIntegerIfIsNumeric(Text1.Text)=FalseThenMsgBox"输入的不是数字,无法计算",,"design"Elsex=Val(Text1)n=Int(Sqr(x))Fori=2TonIfxModi=0ThenExitForNextIfi>nThenLabel3.Caption=X&"是质数"ElseLabel3.Caption=X&"不是质数"EndIfEndIfEndSub5.计算平均成绩PrivateSubForm_Load()Tex
8、t2.Locked=TrueEndSubPrivateSubText1_Change(IndexAsInteger)Text2=""Te
此文档下载收益归作者所有