資源描述:
《vb課后(vb after class)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、vb課后(VBafterclass)Thirdchapters1,theinputladdertoplength,lowerlengthandheight,calculatethetrapezoidalareaandoutput,requiretheuseofInputBoxfunctioninput,usingprintmethodoutput.PrivateSubCommand1_Click()DimaAsSingle,BAsSingle,HAsSingleDimsAsSingleA=Val(InputBox("pleaseinputtheladd
2、eronside"))B=Val(InputBox("pleaseinputtheladderundertheside"))H=Val(InputBox,"entertheladderheight")S=(a+b)*H/2Print"trapezoidarea";sEndSub2,inputhours,minutes,seconds,convertedthemtoseconds,andthenoutput,PrivateSubCommand1_Click()DimaAsSingle,BAsSingle,CAsSingleA=Val(Text1)B=Va
3、l(Text2)C=Val(Text3)S=a*3600+b*60+CLabel4.Caption="thenumberofsecondscorrespondingtotheinputtime:"&SEndSub3,calculatetheperimeterandareaofthehypotenuseofarighttrianglePrivateSubCommand1_Click()DimaAsInteger,BAsIntegerDimCAsSingle,lAsSingle,sAsSingleA=Val(InputBox("pleaseenterthe
4、firstsideofarighttriangle"))B=Val(InputBox("pleaseinputtherighttrianglesecondside"))Print"tworightanglesidesofarighttriangleis:"a,B;C=Sqr(a*a+b*b)L=a+B+CS=a*B/2Print"hypotenuselength:C;Printtheperimeterofrighttriangleis:"L"Printtheareaofrighttriangleis:"s"EndSub4,calculatingtota
5、lscoreandaveragescorePrivateSubCommand1_Click()DimA1AsInteger,A2AsInteger,A3AsInteger,A4AsIntegerDimsumAsInteger,AVGAsSingleA1=Val(InputBox"inputdata")A2=Val(InputBox"inputdata")A3=Val(InputBox"inputdata")A4=Val(InputBox"inputdata")Sum=a1+A2+a3+A4AVG=sum/4Theoverallresults:"MsgB
6、ox&sum&vbCrLf&"average"&AVGEndSub5,absolutevalue,PrivateSubCommand1_Click()DimaAsIntegerA=Val(Text1)Ifa>0ThenText2=aElseIfa=0ThenText2=0ElseText2=-aEndIfEndSub6.CalculatethevalueofthepiecewisefunctionPrivateSubCommand1_Click()DimxAsSingle,yAsSingleX=Text1Ifx>0ThenY=2*x-1ElseIfx<
7、0ThenY=3*x+2ElseY=0EndIfText2.Text=yEndSub7.CalculationbonusPrivateSubCommand1_Click()DimQAsDouble,sAsDoubleQ=Text1.TextSelectCaseQCaseIs<5000S=Q*0.01CaseIs<10000S=(Q-5000)*0.15+50CaseIs<20000S=(Q-10000)*0.2+75+50CaseIs<50000S=(Q-20000)*0.25+200+75+50CaseIs<100000S=(Q-50000)*0.3
8、+750+200+75+50CaseElseS=(Q-100000)*0.35+1500+75