资源描述:
《VB课后答案三四章-朱国华主编.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第3章1.PrivateSubCommand1_Click()DimaAsIntegera=Text1.TextText2.Text=-aText3.Text=a^2Text4.Text=Sqr(Abs(a))Text5.Text=a^3Text6.Text=Abs(a)^(1/3)EndSub2.PrivateSubCommand1_Click()DimxAsInteger,yAsIntegerx=Text1.Texty=Text2.TextText1.Text=yText2.Text=xEndSub3.Priv
2、ateSubCommand1_Click()DimaAsInteger,bAsInteger,cAsIntegerDimx1AsSingle,x2AsSinglea=Val(Text1.Text)b=Val(Text2.Text)c=Val(Text3.Text)'a*x^2+b*x+c=0x1=(-b+Sqr(b^2-4*a*c))/(2*a)x2=(-b-Sqr(b^2-4*a*c))/(2*a)Text4.Text=x1Text5.Text=x2EndSubPrivateSubCommand2_Click()
3、EndEndSub第4章1.PrivateSubCommand1_Click()DimxAsSinglex=Val(Text1.Text)Ifx>=0ThenText2.Text=Sqr(x)ElseMsgBox"该数不能开平方"EndIfEndSub2.PrivateSubCommand1_Click()DimaAsInteger,bAsBooleana=Text1.TextIfaMod5=0AndaMod7=0Thenb=TrueLabel1.Caption="该数能同时被5和7整除"Elseb=FalseLa
4、bel1.Caption="该数不能同时被5和7整除"EndIfEndSub3.PrivateSubCommand1_Click()DimxAsIntegerx=Val(InputBox("请输入一个百分制成绩"))SelectCasexCaseIs>90Print"A"CaseIs>=80Print"B"CaseIs>=70Print"C"CaseIs>=60Print"D"CaseElsePrint"E"EndSelectEndSub4.PrivateSubCommand1_Click()DimnAsInteg
5、er,tAsLong,sAsLongs=0:t=1Forn=1To9t=t*nIfnMod2<>0Thens=s+tNextnPrintsEndSub5.PrivateSubCommand1_Click()DimiAsInteger,sAsDouble,nAsIntegern=Val(InputBox("请输入一个正整数"))s=0Fori=1Tons=s+((-1)^(i+1))/iNextiPrintsEndSubPrivateSubCommand2_Click()DimiAsInteger,sAsLong,n
6、AsInteger,tAsIntegern=Val(InputBox("请输入一个正整数"))s=0Fori=1Tont=t+is=s+tNextiPrintsEndSubPrivateSubCommand3_Click()DimiAsInteger,sAsDouble,nAsInteger,tasintegern=Val(InputBox("请输入一个正整数"))Fori=1Tont=i^2s=s+tNextiPrintsEndSubPrivateSubCommand4_Click()DimiAsInteger,
7、sAsDouble,nAsInteger,tAsIntegern=Val(InputBox("请输入一个正整数"))s=0Fori=1Tont=(-1)^(i-1)*i*(i+1)s=s+tNextiPrintsEndSubPrivateSubCommand5_Click()DimiAsInteger,sAsDouble,nAsInteger,tAsIntegern=Val(InputBox("请输入一个正整数"))Fori=1Tont=t+is=s+1/tNextiPrintsEndSub6.PrivateSub
8、Command1_Click()DimiAsInteger,countAsIntegerFori=1To1000IfiMod2<>0AndiMod13=0Thencount=count+1List1.AddItemiEndIfText1.Text=countNextiEndSub7.PrivateSubCommand1_Click()DimiAsIntege