河南大學(xué)10級VB程序設(shè)計(jì)課后習(xí)題參考答案.doc
《河南大學(xué)10級VB程序設(shè)計(jì)課后習(xí)題參考答案.doc》由會員分享,可在線閱讀,更多相關(guān)《河南大學(xué)10級VB程序設(shè)計(jì)課后習(xí)題參考答案.doc(49頁珍藏版)》請?jiān)谘b配圖網(wǎng)上搜索。
河南大學(xué)09級VB程序設(shè)計(jì)課后習(xí)題參考答案(編碼)2-1PrivateSubForm_Click()ClsEndSubPrivateSubForm_DblClick()FontSize=40FontName=隸書ForeColor=vbRedPrint熱烈慶祝FontSize=60FontName=宋體ForeColor=vbGreenPrint河南大學(xué)運(yùn)動會召開EndSub2-2PrivateSubCommand1_Click()Label1.MoveWidth*Rnd,Height*RndEndSub2-3PrivateSubCommand1_Click()Label1.Visible=TrueEndSubPrivateSubCommand2_Click()Label1.Visible=FalseEndSub2-4PrivateSubTimer1_Timer()Text1.Text=NowCaption=Text1.TextEndSub2-5PrivateSubTimer1_Timer()IfBackColor=vbRedThenBackColor=vbYellowElseBackColor=vbRedEndIfEndSub2-6PrivateSubTimer1_Timer()IfLabel1.Left-Label1.HeightThenLabel1.Top=Label1.Top-100ElseLabel1.Top=Form1.HeightEndIfEndSub3-2PrivateSubForm_Click()DimnAsIntegerRandomizen=Int(90*Rnd)+10)PrintnEndSub3-3PrivateSubTimer1_Timer()ClsPrint河南大學(xué)環(huán)境與規(guī)劃學(xué)院FontSize=Int(71*Rnd+10)EndSub3-4PrivateSubCommand1_Click()n=Text1.TextText2.Text=Hex(Asc(Right(Text1.Text,1)EndSubPrivateSubCommand2_Click()Text1.Text=Text2.Text=Text1.SetFocusEndSub3-5PrivateSubCommand1_Click()DimmAsDatem=Text1.Textn=DateText2.Text=n-mEndSubPrivateSubCommand2_Click()Text1.Text=Text2.Text=Text1.SetFocusEndSub3-6DimbAsStringDimnAsStringDimmAsStringPrivateSubCommand1_Click()m=Left(Text1,1)n=Right(Text1,1)b=Mid(Text1,2,1)Text2.Text=n&b&mEndSubPrivateSubCommand2_Click()Text1.Text=Text2.Text=Text1.SetFocusEndSub3-7PrivateSubForm_click()r=InputBox(請輸入字符)PrintLeft(r,1)&Mid(r,3,1)&Right(r,1)EndSub3-8PrivateSubTimer1_Timer()Label1.FontSize=Rnd*40+10Label1.BackColor=RGB(Rnd*256,Rnd*256,Rnd*256)Label1.ForeColor=QBColor(Int(16*Rnd)EndSub3-10PrivateSubForm_Click()r!=InputBox(請輸入您的工資:)a=r100b=(r-100*a)50c=(r-100*a-b*50)10d=(r-100*a-b*50-c*10)5e=(r-100*a-b*50-c*10-d*5)2f=r-100*a-b*50-c*10-d*5-e*2Print您的工資是:&rPrint100元張數(shù):&aPrint50元張數(shù):&bPrint10元張數(shù):&cPrint5元張數(shù):&dPrint2元張數(shù):&ePrint1元張數(shù):&fEndSub4-1PrivateSubCommand1_Click()DimpAsSingle,rAsSingle,nAsSinglep=Text1r=Text2n=Text3s=p*(1+r)nMsgBox您的本息是:&Round(s,2)EndSub4-2PrivateSubForm_click()DimmaxAsSingle,minAsSinglea!=InputBox(請輸入第一個實(shí)數(shù))b!=InputBox(請輸入第二個實(shí)數(shù))IfabThenPrinta,bElsePrintb,aEndIfEndSub4-3PrivateSubForm_click()Clsa!=InputBox(請輸入年份)IfaMod4=0AndaMod1000&aMod400=0ThenPrint您剛剛輸入的年份為閏年!ElsePrint您剛剛輸入的年份不是閏年!EndIfEndSub4-4PrivateSubForm_click()a!=InputBox(a=)b!=InputBox(b=)c!=InputBox(c=)d!=b*b-4*a*cIfd=0Thenm!=(-b+Sqr(d)/(2*a)n!=(-b-Sqr(d)/(2*a)PrintX1=;m,X2=;nElser=(-b)/(2*a)i=Sqr(Abs(-d)/(2*a)PrintX1=;r&+&Abs(i)&i,X2=;r&-&Abs(i)&iEndIfEndSub4-4(2)Dim a, b, c, d As Singlea = InputBox(輸入數(shù)據(jù))b = InputBox(輸入數(shù)據(jù))c = InputBox(輸入數(shù)據(jù))d = b 2 - 4 * a * cIf d = 0 ThenX1 = (-b + Sqr(d) / (2 * a)X2 = (-b - Sqr(d) / (2 * a)Print x1= & X1 & & x2= & X2Elsex3 = -b / (2 * a) & + & Sqr(-d) / (2 * a) & ix4 = -b / (2 * a) & - & Sqr(-d) / (2 * a) & iPrint x3= & x3 & & x4= & x4End If4-5PrivateSubCommand1_Click()Dimx!x=Text1Ifx60ThenText2=重考!ElseIfx70ThenText2=及格!ElseIfx80ThenText2=中等!ElseIfx90ThenText2=良好!ElseText2=優(yōu)秀!EndIfEndSubPrivateSubCommand2_Click()Text1=Text2=EndSub4-6PrivateSubCommand1_Click()Dimx!x=Text1SelectCasexCaseIs60Text2=重考!CaseIs70Text2=及格!CaseIs80Text2=中等!CaseIs90Text2=良好!CaseElseText2=優(yōu)秀!EndSelectEndSubPrivateSubCommand2_Click()Text1=Text2=EndSub4-7DimsAsStringPrivateSubForm_Click()s=InputBox(請輸入年齡)Ifs30ThenPrint您的年齡為;s,請參加長跑運(yùn)動ElseIfs40ThenPrint您的年齡為;s,請參加跳繩運(yùn)動ElseIfs100Print1-2+3-4+5-6+99-100=;sEndSub4-12PrivateSubForm_Click()DimnAsIntegerDimmAsIntegerDimsAsIntegerm%=InputBox(請輸入正整數(shù)m(m=1),階乘)n%=InputBox(請輸入正整數(shù)n(n=m),階乘)Form=mTont=1Fori=1Tomt=t*iNextis=s+tNextmPrintm!+(m+1)!+n!=;sEndSub4-13PrivateSubForm_click()Dima%Dimb%Dimc%Fora=1To20Forb=1To20Forc=1To20Ifa*a+b*b=c*cThenPrinta,b,cEndIfNextcNextbNextaEndSub4-14PrivateSubForm_click()Forn=1To500Fori=1Ton-1IfnModi=0Thens=s+iNextiIfs=nThenPrinti;s=0NextnPrintEndSub4-15PrivateSubForm_click()DimiAsIntegerDimnAsLongn=1t=1DoWhilet0.00001e=e+ti=i+1n=n*it=1/nLoopPrinte的近似值是;eEndSub51Private Sub Form_Click()Dim i%, x(1 To 5) As StringFor i = LBound(x) To UBound(x)x(i) = InputBox( x ( & i & ) )Next iFor i = UBound(x) To LBound(x) Step -1Print x(i)Next iPrintEnd Sub5-2PrivateSubForm_Click()Dimi%,ss=Array(1,2,3,4,5,6,7,8,9,10)Fori=0To9Ifs(i)Mod3=0ThenPrints(i);iElsePrintEndIfNextiPrintEndSub5-3OptionBase1PrivateSubCommand1_Click()Dimx()x=Array(1,2,3,4,5,6,7,8,9,10)t=x(1)Fori=1To9x(i)=x(i+1)Printx(i);Nextx(10)=tPrintx(i)EndSubPrivateSubCommand2_Click()Dimx()x=Array(1,2,3,4,5,6,7,8,9,10)t=x(10)Fori=9To1Step-1x(i+1)=x(i)Nextix(1)=tFori=1To10Printx(i);NextiEndSub5-4PrivateSubForm_Click()Dima(5,5)Fori=1To5Sum=0Forj=1To5a(i,j)=Int(Rnd*51+10)Sum=Sum+a(i,j)Printa(i,j);NextjPrintSumNextiPrintFori=1To5Forj=1To5Ifi=jThenPrinta(i,j);NextjNextiPrintEndSub5-5PrivateSubForm_Click()Dima()AsIntegerDimMaxAsInteger,iMaxAsInteger,jMaxAsIntegerDimMinAsInteger,iMinAsInteger,jMinAsIntegerM=InputBox(輸入M)N=InputBox(輸入N)ReDima(M,N)Fori=1ToMForj=1ToNa(i,j)=Int(Rnd*900)+100NextjNextiFori=1ToMForj=1ToNPrinta(i,j);NextjPrintNextiMax=a(1,1):Min=a(1,1)Fori=1ToMForj=1ToNIfa(i,j)MaxThenMax=a(i,j):iMax=i:jMax=jfa(i,j)MinThenMin=a(i,j):iMin=i:jMin=jNextjNextiPrintMax=;Max,iMax=;iMax,jMax=;jMaxPrintMin=;Min,iMin=;iMin,jMin=;jMinEraseaEndSub5-6PrivateSubForm_Click()n=InputBox(n)ReDima(n,n)Fori=1TonForj=1TonIfi=jThena(i,j)=1Elsea(i,j)=0EndIfNextjNextiFori=1TonForj=1TonPrinta(i,j);NextjPrintNextiEraseaEndSub5-7PrivateSubForm_Click()DimxAsVariantx=Array(1,2,3,4,5,6,7,8,9,10)Fori=1To10Printx(i);NextiPrintFori=1To7x(i)=x(i+3)Printx(i);NextiPrintReDimPreservex(i)x=Array(1,2,3,4,5,6,7)ori=1To7Printx(i);NextiPrintEndSub5-8OptionBase1PrivateSubCommand1_Click(IndexAsInteger)SelectCaseIndexCase1Text3=Val(Text1)+Val(Text2)Case2Text3=Text1-Text2Case3Text3=Text1*Text2Case4Text3=Text1/Text2EndSelectEndSub6-1PrivateSubForm_click()DimxAsSingleDimyAsSingleDimzAsSinglex=InputBox(請輸入圓柱體的半徑)y=InputBox(請輸入圓柱體的高度)volumex,y,zPrint圓柱體的體積為;zEndSub6-2窗體模塊PrivateSubForm_click()Dima!,b!,c!a=InputBox(請輸入圓柱體的半徑)b=InputBox(請輸入圓柱體的高度)c=volume(a,b)Print圓柱體的體積為;cEndSub標(biāo)準(zhǔn)模塊Functionvolume(rAsSingle,hAsSingle)AsSinglevolume=3.14*r*r*hEndFunction6-3PrivateSubForm_Click()Dimy%y=InputBox(請輸入一個整數(shù))Callweek(y)EndSub6-4窗體模塊PrivateSubForm_click()DimaAsInteger,bAsStringa=InputBox(請輸入一個整數(shù))b=week(a)Printb標(biāo)準(zhǔn)模塊Functionweek(sAsInteger)AsStringSelectCasesCase0week=星期日Case1week=星期一Case2week=星期二Case3week=星期三Case4week=星期四Case5week=星期五Case6week=星期六CaseElseMsgBox數(shù)據(jù)無效EndSelectEndFunction6-5窗體模塊PrivateSubForm_click()DimnAsSingle,wAsStringn=InputBox(請輸入一個正整數(shù))SelectCasewCasejudge=0Print此數(shù)為偶數(shù)CaseElsePrint此數(shù)為奇數(shù)PrintwEndSelectEndSub標(biāo)準(zhǔn)模塊Functionw(nAsSingle)AsStringw=n2SelectCasewCasew=0Print此數(shù)為偶數(shù)CaseElsePrint此數(shù)為奇數(shù)EndFunction6-7SublenUL(ByValsAsString,U%,L%)DimiAsIntegerFori=1ToLen(s)SelectCaseMid(s,i,1)CaseAToZU=U+1CaseaTozL=L+1EndSelectNextiEndSubPrivateSubCommand1_Click()DimU%,L%CalllenUL(Text1,U,L)Text2=UText3=LEndSubPrivateSubCommand2_Click()Text1=Text2=Text3=Text1.SetFocusEndSub7-1PrivateSubCommand1_Click()Image1.Picture=LoadPicture(c:圖片picture5.JPG)EndSubPrivateSubCommand2_Click()Image1.Picture=LoadPicture(c:圖片picture3.JPG)EndSubPrivateSubCommand3_Click()Image1.Picture=LoadPicture(c:圖片picture4.JPG)EndSub7-2PrivateSubCommand1_Click()StaticaAsIntegera=a+1IfaMod20ThenImage1.Picture=LoadPicture(c:圖片p2.JPG)Image2.Picture=LoadPicture(c:圖片p1.JPG)ElseImage1.Picture=LoadPicture(c:圖片p1.JPG)Image2.Picture=LoadPicture(c:圖片p2.JPG)EndIfEndSubPrivateSubForm_Load()Image1.Picture=LoadPicture(c:圖片p1.JPG)Image2.Picture=LoadPicture(c:圖片p2.JPG)EndSub7-3PrivateSubTimer1_Timer()Form1.Picture=Image3.PictureImage3.Picture=Image2.PictureImage2.Picture=Image1.PictureImage1.Picture=Form1.PictureEndSub7-4PrivateSubForm_Load()Timer1.Enabled=FalseEndSubPrivateSubTimer1_Timer()IfImage2.Top=-Image2.HeightThenImage2.Top=Image2.Top-100ElseImage2.Top=-Image2.HeightEndIfEndSub7-5PrivateSubForm_Load()HScroll1.Min=0HScroll1.Max=Image1.WidthImage1.Width=0EndSubPrivateSubHScroll1_Scroll()Image1.Width=HScroll1Label1=當(dāng)前圖片寬度:&HScroll1.ValueEndSub7-6PrivateSubCommand1_Click()Fori=ProgressBar1.MinToProgressBar1.MaxProgressBar1.Value=i(Forj=1To20000Nextj)(延時)NextiEndSub7-7PrivateSubCommand1_Click()a=IIf(Option1,男,女)b=IIf(Option3,碩士,博士)c=IIf(Check1,音樂,)d=IIf(Check2,演講,)e=IIf(Check3,體育,)f=IIf(Check4,集郵,)Text2=姓名:&Text1.Text&,&性別:&a&,&學(xué)歷:&b&,&特長:&c&,&d&,&e&,&fEndSubPrivateSubCommand2_Click()Text1=Text2=Text1.SetFocusEndSub7-8PrivateSubForm_Load()Combo1.AddItem河南省Combo1.AddItem開封市Combo1.AddItem河南大學(xué)Combo1.AddItem金明校區(qū)Combo1.AddItem環(huán)境與規(guī)劃學(xué)院Combo1.AddItem09級Combo1.AddItem地理科學(xué)專業(yè)Combo1.AddItem劉彬Combo1.AddItem畢業(yè)于Combo1.AddItem湖南省Combo1.AddItem衡山縣Combo1.AddItem第二中學(xué)Combo1.AddItem218班EndSubPrivateSubCombo1_Click()List1.AddItemCombo1.TextEndSubPrivateSubList1_DblClick()List1.RemoveItemList1.ListIndexEndSub8-1DimxAsSingle,yAsSinglePrivateSubPt1_Click()Pt1.Scale(0,100)-(100,0)Pt1.DrawWidth=2Forx=0To100Step0.02Pt1.PSet(x,2),vbRedNextxFory=0To100Step0.02Pt1.PSet(2,y),vbRedNextyPt1.CurrentX=2Pt1.CurrentY=5Pt1.Print(0,0)EndSub8-2PrivateSubP1_Click()P1.Scale(0,100)-(100,0)P1.FillStyle=7P1.DrawWidth=5P1.FillColor=vbGreenP1.Line(10,90)-(90,10),vbRed,BEndSub8-3PrivateSubForm_click()Scale(-100,100)-(100,-100)Line(-100,0)-(100,0)Line(0,-100)-(0,100)CurrentX=2CurrentY=6Print(0,0)EndSub8-4PrivateSubForm_click()Scale(-100,100)-(100,-100)Line(-100,0)-(100,0)Line(0,-100)-(0,100)Forx=-100To100Step0.02y=10*Sin(x)-10*Cos(2*x)PSet(x,y),vbRedNextxEndSub8-7PrivateSubForm_Click()Timer1.Enabled=TrueEndSubPrivateSubTimer1_Timer()RandomizeScale(-120,120)-(120,-120)DrawWidth=2Ifr100Thenr=r+2Forr=0To100Circle(0,0),r,RGB(255*Rnd,255*Rnd,255*Rnd)NextrEndIfEndSub9-1PrivateSubText1_KeyPress(KAsInteger)K=K+3EndSub9-2PrivateSubText1_KeyPress(KAsInteger)SelectCaseKCase48To57K=KCaseElseK=0EndSelectEndSub9-6PrivateSubCommand1_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)MousePointer=5EndSubPrivateSubText1_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)MousePointer=11EndSubPrivateSubPicture1_Click()MouseIcon=Picture1.MouseIconPicture1.MouseIcon=Image1.MouseIconImage1.MouseIcon=Form1.MouseIconEndSub9-7SubForm_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)IfShift=vbCtrlMaskAndButton=vbLeftButtonThenPrintCtrl+左鍵+移動IfShift=vbAltMaskAndButton=vbRightButtonThenPrintAlt+右鍵+移動EndSubSubForm_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)ClsEndSub9-8SubPicture1_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)IfButton=vbLeftButtonThenPicture1.PrintStr(X)+,+Str(Y)BackColor=RGB(Rnd*256,Rnd*256,Rnd*256)EndSub10-1PrivateSubCommand1_Click()Opend:data1.txtForOutputAs#1Write#1,601,楊大昌;4550Write#1,603,李文圣;3886Write#1,605,張燕;2235Close#1EndSubPrivateSubCommand2_Click()Opend:data1.txtForInputAs#2DoWhileNotEOF(2)Input#2,X1,X2,x3PrintX1,X2,x3LoopCloseEndSub10-2PrivateSubCommand1_Click()Opend:data1.txtForAppendAs#3Write#3,Text1,Text2,Text3Text1=Text2=Text3=CloseEndSubPrivateSubCommand2_Click()CloseEndEndSub10-5PrivateSubForm_Click()DimsumAsLongForn=1To100Step2sum=sum+nNextnPrintsumEndSubPrivateSubForm_Load()Opend:data5.txtForOutputAs#1Forn=1To100Step1Print#1,n;NextnCloseEndSub10-6PrivateSubForm_Click()DimsumAsIntegerForn=10To100Step10sum=sum+nNextPrintsumEndSubPrivateSubForm_Load()Opend:data6.datForRandomAs#1Forn=1To100Put#1,nNextEndSub11-1PrivateSubCommand1_Click()CommonDialog1.Action=3Text1.BackColor=CommonDialog1.ColorEndSubPrivateSubCommand2_Click()CommonDialog1.Flags=263CommonDialog1.Action=4Text1.FontSize=CommonDialog1.FontSizeText1.FontName=CommonDialog1.FontNameText1.FontBold=CommonDialog1.FontBoldText1.FontStrikethru=CommonDialog1.FontStrikethruText1.ForeColor=CommonDialog1.ColorText1.FontUnderline=CommonDialog1.FontUnderlineEndSubPrivateSubCommand3_Click()CommonDialog1.Action=2EndSub11-2PrivateSubCommand1_Click()CD1.InitDir=C:DocumentsandSettingsAdministrator桌面CD1.Filter=圖片|*.jpg|文本文件|*.txtCD1.ShowOpenIfCD1.FilterIndex=1ThenImage1.Picture=LoadPicture(CD1.FileName)ElseOpenCD1.FileNameForInputAs#1DoWhileNotEOF(1)LineInput#1,nText1=Text1+n+vbNewLineLoopEndIfEndSub113Private Sub Form_Load()Text1.Text = 河南大學(xué)首頁Text1.FontName = 黑體Text1.FontSize = 20End SubPrivate Sub Form_Resize()Text1.Left = 50Text1.Top = 50Text1.Width = Width - 500Text1.Height = Height - 1000End SubPrivate Sub mnublue_Click()Text1.ForeColor = vbBlueEnd SubPrivate Sub mnuclear_Click()Text1.Text = End SubPrivate Sub mnugreen_Click()Text1.ForeColor = vbGreenEnd SubPrivate Sub mnured_Click()Text1.ForeColor = vbRedEnd Sub11-4PrivateSubForm_Resize()Text1.Left=50Text1.Top=50Text1.Width=Width-2000Text1.Height=Height-5000EndSubPrivateSubmnuName_Click(IndexAsInteger)SelectCaseIndexCase5Text1.FontName=宋體Case10Text1.FontName=黑體Case15Text1.FontName=隸書EndSelectEndSub11-5Private Sub mnuinput_Click()Dim a As Integera = InputBox(輸入整數(shù))If a 0 Then MsgBox (輸入無效)Label4.Caption = aEnd SubPrivate Sub mnuoct_Click()Dim a As Integera = InputBox(輸入整數(shù))If a 0 Then MsgBox (輸入無效)Label5.Caption = Oct(a)End SubPrivate Sub mnuhex_Click()Dim a As Integera = InputBox(輸入整數(shù))If a 0 Then MsgBox (輸入無效)Label6.Caption = Hex(a)End Sub11-6PrivateSubForm_Load()Text1.Width=WidthText1.Height- 1.請仔細(xì)閱讀文檔,確保文檔完整性,對于不預(yù)覽、不比對內(nèi)容而直接下載帶來的問題本站不予受理。
- 2.下載的文檔,不會出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請點(diǎn)此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
9.9 積分
下載 |
- 配套講稿:
如PPT文件的首頁顯示word圖標(biāo),表示該P(yáng)PT已包含配套word講稿。雙擊word圖標(biāo)可打開word文檔。
- 特殊限制:
部分文檔作品中含有的國旗、國徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計(jì)者僅對作品中獨(dú)創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- 河南大學(xué) 10 VB 程序設(shè)計(jì) 課后 習(xí)題 參考答案
鏈接地址:http://italysoccerbets.com/p-7972467.html