3、排序后:";a,b,cEndSub4、輸入x的值,輸出對(duì)應(yīng)的值。y=10+2x(00Andx<=10Theny=10+2*xMsgBox"x="&x&"y="&yElseIfx<=20Theny=50-xMsgBox"x="&x&"y="&yElseIfx<=30Theny=30Msg
4、Box"x="&x&"y="&yElseIfx<=40Theny=60-xMsgBox"x="&x&"y="&yElseMsgBox"x="&x&"不在統(tǒng)計(jì)數(shù)據(jù)的范圍內(nèi)"EndIfEndSub(二)、PrivateSubCommand1_Click()Dimx%,y%x=InputBox("x")SelectCasexCaseIs<=10y=10+2*xCaseIs<=20y=50-xCaseIs<=30y=30CaseIs<=40y=60-xCaseElseMsgBox"輸入不合法"EndSelectPrint"x=";x,
5、"y=";yEndSub5、編寫一個(gè)程序,輸出給定的某年某月的天數(shù)。程序代碼:PrivateSubCommand1_Click()DimyearAsInteger,monthAsInteger,dayAsIntegeryear=CInt(Text1.Text)month=CInt(Text2.Text)SelectCasemonthCase1,3,5,7,8,10,12day=31Case4,6,9,11day=30Case2IfyearMod4=0AndyearMod100<>0OryearMod400=0Thenday=2
6、9Elseday=28EndIfCaseElseday=0EndSelectIfday<>0ThenMsgBoxyear&"年"&month&"月有"&day&"天"ElseMsgBox"輸入的月份不符合實(shí)際!"EndIfEndSub6、求S=1+2+3+....+100的累加和。程序代碼:(一)、For….Next循環(huán)PrivateSubCommand1_Click()Dimi%,s%s=0Fori=1To100s=s+iNextiPrint"s=";sEndSub(二)、DoWhile…Loop循環(huán)PrivateSubCo
7、mmand1_Click()Dimi%,s%s=0:i=1DoWhilei<=100s=s+ii=i+1LoopPrint"s=";sEndSub(三)、DoUntil….LoopPrivateSubCommand1_Click()Dimi%,s%s=0:i=1DoUntili>100s=s+ii=i+1LoopPrint"s=";sEndSub7、接6,如果累加達(dá)到1000時(shí)馬上終止循環(huán),同時(shí)輸出此時(shí)循環(huán)變量i的值。程序代碼:(一)、PrivateSubCommand1_Click()Dimi%,s%s=0Fori=1To1
8、00s=s+iIfs>=1000ThenExitForNextiPrint"s=";s,"i=";iEndSub(二)、PrivateSubCommand1_Click()Dimi%,s%s=0:i=0Whiles<1000i=i+1s=s+iWendPrint"s=";s,